]> git.lyx.org Git - features.git/blob - src/output_xhtml.cpp
This is the custom stream for XHTML output. It isn't used yet, and
[features.git] / src / output_xhtml.cpp
1 /**
2  * \file output_xhtml.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Richard Heck
7  * 
8  * This code is based upon output_docbook.cpp
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "output_xhtml.h"
16
17 #include "Buffer.h"
18 #include "buffer_funcs.h"
19 #include "BufferParams.h"
20 #include "Counters.h"
21 #include "Layout.h"
22 #include "OutputParams.h"
23 #include "Paragraph.h"
24 #include "ParagraphList.h"
25 #include "ParagraphParameters.h"
26 #include "sgml.h"
27 #include "Text.h"
28 #include "TextClass.h"
29
30 #include "support/lassert.h"
31 #include "support/debug.h"
32 #include "support/lstrings.h"
33
34 #include <vector>
35
36 using namespace std;
37 using namespace lyx::support;
38
39 namespace lyx {
40
41 namespace html {
42
43 docstring escapeChar(char_type c)
44 {
45         docstring str;
46         switch (c) {
47         case ' ':
48                 str += " ";
49                 break;
50         case '&':
51                 str += "&amp;";
52                 break;
53         case '<':
54                 str += "&lt;";
55                 break;
56         case '>':
57                 str += "&gt;";
58                 break;
59         default:
60                 str += c;
61                 break;
62         }
63         return str;
64 }
65
66
67 // escape what needs escaping
68 docstring htmlize(docstring const & str) {
69         odocstringstream d;
70         docstring::const_iterator it = str.begin();
71         docstring::const_iterator en = str.end();
72         for (; it != en; ++it)
73                 d << escapeChar(*it);
74         return d.str();
75 }
76
77
78 bool isFontTag(string const & s)
79 {
80         return s == "em" || s == "strong"; // others?
81 }
82
83
84 ////////////////////////////////////////////////////////////////
85 ///
86 /// XHTMLStream
87 ///
88 ////////////////////////////////////////////////////////////////
89
90 XHTMLStream::XHTMLStream(odocstream & os) 
91                 :os_(os)
92 {}
93
94
95 void XHTMLStream::cr() 
96 {
97         // tabs?
98         os_ << std::endl;
99 }
100
101
102 bool XHTMLStream::closeFontTags()
103 {
104         // first, we close any open font tags we can close
105         StartTag curtag = tag_stack_.back();
106         while (isFontTag(curtag.tag_)) {
107                 os_ << "</" << curtag.tag_ << ">";
108                 tag_stack_.pop_back();
109                 if (tag_stack_.empty())
110                         // this probably shouldn't happen, since then the
111                         // font tags weren't in any other tag. but that
112                         // problem will likely be caught elsewhere.
113                         return true;
114                 curtag = tag_stack_.back();
115         }
116         // so we've hit a non-font tag. let's see if any of the
117         // remaining tags are font tags.
118         TagStack::const_iterator it = tag_stack_.begin();
119         TagStack::const_iterator en = tag_stack_.end();
120         bool noFontTags = true;
121         for (; it != en; ++it) {
122                 if (isFontTag(it->tag_)) {
123                         LYXERR0("Font tag `" << it->tag_ << "' still open in closeFontTags().");
124                         noFontTags = false;
125                 }
126         }
127         return noFontTags;
128 }
129
130
131 void XHTMLStream::clearTagDeque()
132 {
133         while (!pending_tags_.empty()) {
134                 StartTag const & tag = pending_tags_.front();
135                 // tabs?
136                 os_ << "<" << tag.tag_ << " " << tag.attr_ << ">";
137                 tag_stack_.push_back(tag);
138                 pending_tags_.pop_front();
139         }
140 }
141
142 XHTMLStream & XHTMLStream::operator<<(docstring const & d)
143 {
144         // I'm tempted to make sure here that there are no tags in the input
145         clearTagDeque();
146         os_ << htmlize(d);
147         return *this;
148 }
149
150
151 /*
152 XHTMLStream & XHTMLStream::operator<<(char_type c)
153 {
154         clearTagDeque();
155         os_ << escapeChar(c);
156         return *this;
157 }
158 */
159
160
161 XHTMLStream & XHTMLStream::operator<<(StartTag const & tag) 
162 {
163         pending_tags_.push_back(tag);
164         if (tag.keepempty_)
165                 clearTagDeque();
166         return *this;
167 }
168
169
170 XHTMLStream & XHTMLStream::operator<<(CompTag const & tag) 
171 {
172         clearTagDeque();
173         // tabs?
174         os_ << "<" << tag.tag_ << " " << tag.attr_ << " />";
175         return *this;
176 }
177
178
179 bool    XHTMLStream::isTagOpen(string const & stag)
180 {
181         TagStack::const_iterator sit = tag_stack_.begin();
182         TagStack::const_iterator const sen = tag_stack_.end();
183         for (; sit != sen; ++sit)
184                 // we could check for the
185                 if (sit->tag_ == stag) 
186                         return true;
187         return false;
188 }
189
190
191 // this is complicated, because we want to make sure that
192 // everything is properly nested. the code ought to make 
193 // sure of that, but we won't assert (yet) if we run into
194 // a problem. we'll just output error messages and try our
195 // best to make things work.
196 XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
197 {
198         // first make sure we're not closing an empty tag
199         if (!pending_tags_.empty()) {
200                 StartTag const & stag = pending_tags_.back();
201                 if (etag.tag_ == stag.tag_)  {
202                         // we have <tag></tag>, so we discard it and remove it 
203                         // from the pending_tags_.
204                         pending_tags_.pop_back();
205                         return *this;
206                 }
207                 // there is a pending tag that isn't the one we are trying
208                 // to close. 
209                 // is this tag itself pending?
210                 // non-const iterators because we may call erase().
211                 TagDeque::iterator dit = pending_tags_.begin();
212                 TagDeque::iterator const den = pending_tags_.end();
213                 for (; dit != den; ++dit) {
214                         if (dit->tag_ == etag.tag_) {
215                                 // it was pending, so we just erase it
216                                 LYXERR0("Tried to close pending tag `" << etag.tag_ 
217                                         << "' when other tags were pending. Tag discarded.");
218                                 pending_tags_.erase(dit);
219                                 return *this;
220                         }
221                 }
222                 // so etag isn't itself pending. is it even open?
223                 if (!isTagOpen(etag.tag_)) {
224                         LYXERR0("Tried to close `" << etag.tag_ 
225                                  << "' when tag was not open. Tag discarded.");
226                         return *this;
227                 }
228                 // ok, so etag is open.
229                 // our strategy will be as below: we will do what we need to 
230                 // do to close this tag.
231                 LYXERR0("Closing tag `" << etag.tag_ 
232                         << "' when other tags are pending. Discarded pending tags:");
233                 for (dit = pending_tags_.begin(); dit != den; ++dit)
234                         LYXERR0(dit->tag_);
235                 // clear the pending tags...
236                 pending_tags_.clear();
237                 // ...and then just fall through.
238         }
239
240         // is the tag we are closing the last one we opened?
241         if (etag.tag_ == tag_stack_.back().tag_) {
242                 // output it...
243                 os_ << "</" << etag.tag_ << ">";
244                 // ...and forget about it
245                 tag_stack_.pop_back();
246                 return *this;
247         } 
248         
249         // we are trying to close a tag other than the one last opened. 
250         // let's first see if this particular tag is still open somehow.
251         if (!isTagOpen(etag.tag_)) {
252                 LYXERR0("Tried to close `" << etag.tag_ 
253                         << "' when tag was not open. Tag discarded.");
254                 return *this;
255         }
256         
257         // so the tag was opened, but other tags have been opened since
258         // and not yet closed.
259         // if it's a font tag, though...
260         if (isFontTag(etag.tag_)) {
261                 // it won't be a problem if the other tags open since this one
262                 // are also font tags.
263                 TagStack::const_reverse_iterator rit = tag_stack_.rbegin();
264                 TagStack::const_reverse_iterator ren = tag_stack_.rend();
265                 for (; rit != ren; ++rit) {
266                         if (!isFontTag(rit->tag_)) {
267                                 // we'll just leave it and, presumably, have to close it later.
268                                 LYXERR0("Unable to close font tag `" << etag.tag_ 
269                                         << "' due to open non-font tags.");
270                                 return *this;
271                         }
272                 }
273                 
274                 // so we have e.g.:
275                 //    <em>this is <strong>bold
276                 // and are being asked to closed em. we want:
277                 //    <em>this is <strong>bold</strong></em><strong>
278                 // first, we close the intervening tags...
279                 StartTag curtag = tag_stack_.back();
280                 // ...remembering them in a stack.
281                 TagStack fontstack;
282                 while (curtag.tag_ != etag.tag_) {
283                         os_ << "</" << curtag.tag_ << ">";
284                         fontstack.push_back(curtag);
285                         tag_stack_.pop_back();
286                         curtag = tag_stack_.back();
287                 }
288                 // now close our tag...
289                 os_ << "</" << etag.tag_ << ">";
290                 // ...and restore the other tags.
291                 rit = fontstack.rbegin();
292                 ren = fontstack.rend();
293                 for (; rit != ren; ++rit)
294                         pending_tags_.push_back(*rit);
295                 return *this;
296         }
297         
298         // it wasn't a font tag.
299         // so other tags were opened before this one and not properly closed. 
300         // so we'll close them, too. that may cause other issues later, but it 
301         // at least guarantees proper nesting.
302         LYXERR0("Closing tag `" << etag.tag_ 
303                 << "' when other tags are open, namely:");
304         StartTag curtag = tag_stack_.back();
305         while (curtag.tag_ != etag.tag_) {
306                 LYXERR0(curtag.tag_);
307                 os_ << "</" << curtag.tag_ << ">";
308                 tag_stack_.pop_back();
309                 curtag = tag_stack_.back();
310         }
311         // curtag is now the one we actually want.
312         os_ << "</" << curtag.tag_ << ">";
313         tag_stack_.pop_back();
314         
315         return *this;
316 }
317
318
319 ///////////////////////////////////////////////////////////////
320 // OLD STUFF to be replaced
321
322 // FIXME This needs to be protected somehow.
323 static vector<string> taglist;
324
325 bool openTag(odocstream & os, string const & tag, string const & attr)
326 {
327         if (tag.empty())
328                 return false;
329         os << from_ascii("<" + tag + (attr.empty() ? "" : " " + attr) + ">");
330         taglist.push_back(tag);
331         return true;
332 }
333
334
335 bool closeTag(odocstream & os, string const & tag)
336 {
337         if (tag.empty())
338                 return false;
339         // FIXME Check for proper nesting
340         if (taglist.empty()){
341                 LYXERR0("Last tag not found when closing `" << tag << "'!");
342                 return false;
343         }
344         string const & lasttag = taglist.back();
345         if (lasttag != tag)  {
346                 LYXERR0("Last tag was `" << lasttag << "' when closing `" << tag << "'!");
347                 return false;
348         }
349         taglist.pop_back();
350         os << from_ascii("</" + tag + ">");
351         return true;
352 }
353
354
355
356 } // html
357
358 namespace {
359
360 bool openTag(odocstream & os, Layout const & lay)
361 {
362         return html::openTag(os, lay.htmltag(), lay.htmlattr());
363 }
364
365
366 bool closeTag(odocstream & os, Layout const & lay)
367 {
368         return html::closeTag(os, lay.htmltag());
369 }
370
371
372 bool openLabelTag(odocstream & os, Layout const & lay)
373 {
374         return html::openTag(os, lay.htmllabeltag(), lay.htmllabelattr());
375 }
376
377
378 bool closeLabelTag(odocstream & os, Layout const & lay)
379 {
380         return html::closeTag(os, lay.htmllabeltag());
381 }
382
383
384 bool openItemTag(odocstream & os, Layout const & lay)
385 {
386         return html::openTag(os, lay.htmlitemtag(), lay.htmlitemattr());
387 }
388
389
390 bool closeItemTag(odocstream & os, Layout const & lay)
391 {
392         return html::closeTag(os, lay.htmlitemtag());
393 }
394
395 // end of old stuff to be replaced
396 ///////////////////////////////////////////////////////////////
397
398 ParagraphList::const_iterator searchParagraphHtml(
399         ParagraphList::const_iterator p,
400         ParagraphList::const_iterator const & pend)
401 {
402         for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p)
403                 ;
404
405         return p;
406 }
407
408
409 ParagraphList::const_iterator searchEnvironmentHtml(
410                 ParagraphList::const_iterator const pstart,
411                 ParagraphList::const_iterator const & pend)
412 {
413         ParagraphList::const_iterator p = pstart;
414         Layout const & bstyle = p->layout();
415         size_t const depth = p->params().depth();
416         for (++p; p != pend; ++p) {
417                 Layout const & style = p->layout();
418                 // It shouldn't happen that e.g. a section command occurs inside
419                 // a quotation environment, at a higher depth, but as of 6/2009,
420                 // it can happen. We pretend that it's just at lowest depth.
421                 if (style.latextype == LATEX_COMMAND)
422                         return p;
423                 // If depth is down, we're done
424                 if (p->params().depth() < depth)
425                         return p;
426                 // If depth is up, we're not done
427                 if (p->params().depth() > depth)
428                         continue;
429                 // Now we know we are at the same depth
430                 if (style.latextype == LATEX_PARAGRAPH
431                     || style.latexname() != bstyle.latexname())
432                         return p;
433         }
434         return pend;
435 }
436
437
438 ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
439                                             odocstream & os,
440                                             OutputParams const & runparams,
441                                             Text const & text,
442                                             ParagraphList::const_iterator const & pbegin,
443                                             ParagraphList::const_iterator const & pend)
444 {
445         ParagraphList::const_iterator const begin = text.paragraphs().begin();
446         ParagraphList::const_iterator par = pbegin;
447         for (; par != pend; ++par) {
448                 Layout const & lay = par->layout();
449                 if (!lay.counter.empty())
450                         buf.params().documentClass().counters().step(lay.counter);
451                 // FIXME We should see if there's a label to be output and
452                 // do something with it.
453                 if (par != pbegin)
454                         os << '\n';
455
456                 // FIXME Should we really allow anything other than 'p' here?
457                 
458                 // If we are already in a paragraph, and this is the first one, then we
459                 // do not want to open the paragraph tag.
460                 bool const opened = 
461                         (par == pbegin && runparams.html_in_par) ? false : openTag(os, lay);
462                 docstring const deferred = par->simpleLyXHTMLOnePar(buf, os, runparams,
463                                 text.outerFont(distance(begin, par)));
464
465                 // We want to issue the closing tag if either:
466                 //   (i)  We opened it, and either html_in_par is false,
467                 //        or we're not in the last paragraph, anyway.
468                 //   (ii) We didn't open it and html_in_par is true, 
469                 //        but we are in the first par, and there is a next par.
470                 ParagraphList::const_iterator nextpar = par;
471                 nextpar++;
472                 bool const needClose = 
473                         (opened && (!runparams.html_in_par || nextpar != pend))
474                         || (!opened && runparams.html_in_par && par == pbegin && nextpar != pend);
475                 if (needClose) {
476                         closeTag(os, lay);
477                         os << '\n';
478                 }
479                 if (!deferred.empty())
480                         os << deferred << '\n';
481         }
482         return pend;
483 }
484
485
486 ParagraphList::const_iterator makeBibliography(Buffer const & buf,
487                                 odocstream & os,
488                                 OutputParams const & runparams,
489                                 Text const & text,
490                                 ParagraphList::const_iterator const & pbegin,
491                                 ParagraphList::const_iterator const & pend) 
492 {
493         os << "<h2 class='bibliography'>" 
494            << pbegin->layout().labelstring(false) 
495            << "</h2>\n"
496            << "<div class='bibliography'>\n";
497                         makeParagraphs(buf, os, runparams, text, pbegin, pend);
498         os << "</div>";
499         return pend;
500 }
501
502
503 namespace {
504         bool isNormalEnv(Layout const & lay)
505         {
506                 return lay.latextype == LATEX_ENVIRONMENT;
507         }
508 }
509
510 ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
511                                               odocstream & os,
512                                               OutputParams const & runparams,
513                                               Text const & text,
514                                               ParagraphList::const_iterator const & pbegin,
515                                               ParagraphList::const_iterator const & pend) 
516 {
517         ParagraphList::const_iterator const begin = text.paragraphs().begin();
518         ParagraphList::const_iterator par = pbegin;
519         Layout const & bstyle = par->layout();
520         depth_type const origdepth = pbegin->params().depth();
521
522         // Open tag for this environment
523         bool const main_tag_opened = openTag(os, bstyle);
524         os << '\n';
525
526         // we will on occasion need to remember a layout from before.
527         Layout const * lastlay = 0;
528
529         while (par != pend) {
530                 Layout const & style = par->layout();
531                 // the counter only gets stepped if we're in some kind of list,
532                 // or if it's the first time through.
533                 if (!style.counter.empty() && (par == pbegin || !isNormalEnv(style)))
534                         buf.params().documentClass().counters().step(style.counter);
535                 ParagraphList::const_iterator send;
536                 // this will be positive, if we want to skip the initial word
537                 // (if it's been taken for the label).
538                 pos_type sep = 0;
539
540                 switch (style.latextype) {
541                 case LATEX_ENVIRONMENT:
542                 case LATEX_LIST_ENVIRONMENT:
543                 case LATEX_ITEM_ENVIRONMENT: {
544                         // There are two possiblities in this case. 
545                         // One is that we are still in the environment in which we 
546                         // started---which we will be if the depth is the same.
547                         if (par->params().depth() == origdepth) {
548                                 LASSERT(bstyle == style, /* */);
549                                 if (lastlay != 0) {
550                                         closeItemTag(os, *lastlay);
551                                         lastlay = 0;
552                                 }
553                                 bool item_tag_opened = false;
554                                 bool const labelfirst = style.htmllabelfirst();
555                                 bool madelabel = false;
556                                 if (isNormalEnv(style)) {
557                                         // in this case, we print the label only for the first 
558                                         // paragraph (as in a theorem).
559                                         item_tag_opened = openItemTag(os, style);
560                                         if (par == pbegin && style.htmllabeltag() != "NONE") {
561                                                 docstring const lbl = 
562                                                                 pbegin->expandLabel(style, buf.params(), false);
563                                                 if (!lbl.empty()) {
564                                                         bool const label_tag_opened = openLabelTag(os, style);
565                                                         os << lbl;
566                                                         if (label_tag_opened)
567                                                                 closeLabelTag(os, style);
568                                                 }
569                                                 os << '\n';
570                                         }
571                                 }       else { // some kind of list
572                                         if (!labelfirst)
573                                                 item_tag_opened = openItemTag(os, style);
574                                         if (style.labeltype == LABEL_MANUAL
575                                             && style.htmllabeltag() != "NONE") {
576                                                 madelabel = openLabelTag(os, style);
577                                                 sep = par->firstWordLyXHTML(os, runparams);
578                                                 if (madelabel)
579                                                         closeLabelTag(os, style);
580                                                 os << '\n';
581                                         }
582                                         else if (style.labeltype != LABEL_NO_LABEL
583                                                  && style.htmllabeltag() != "NONE") {
584                                                 madelabel = openLabelTag(os, style);
585                                                 os << par->expandLabel(style, buf.params(), false);
586                                                 if (madelabel)
587                                                         closeLabelTag(os, style);
588                                                 os << '\n';
589                                         }
590                                         if (labelfirst)
591                                                 item_tag_opened = openItemTag(os, style);
592                                         else if (madelabel)
593                                                 os << "<span class='" << style.name() << "inneritem'>";
594                                 }
595                                 par->simpleLyXHTMLOnePar(buf, os, runparams, 
596                                         text.outerFont(distance(begin, par)), sep);
597                                 if (!isNormalEnv(style) && !labelfirst && madelabel)
598                                         os << "</span>";
599                                 ++par;
600                                 if (item_tag_opened) {
601                                         // We may not want to close the tag yet, in particular,
602                                         // if we're not at the end...
603                                         if (par != pend 
604                                     //  and are doing items...
605                                      && style.latextype == LATEX_ITEM_ENVIRONMENT
606                                      // and if the depth has changed...
607                                      && par->params().depth() != origdepth) {
608                                      // then we'll save this layout for later, and close it when
609                                      // we get another item.
610                                                 lastlay = &style;
611                                         } else
612                                                 closeItemTag(os, style);
613                                         os << '\n';
614                                 }
615                         }
616                         // The other possibility is that the depth has increased, in which
617                         // case we need to recurse.
618                         else {
619                                 send = searchEnvironmentHtml(par, pend);
620                                 par = makeEnvironmentHtml(buf, os, runparams, text, par, send);
621                         }
622                         break;
623                 }
624                 case LATEX_PARAGRAPH:
625                         send = searchParagraphHtml(par, pend);
626                         par = makeParagraphs(buf, os, runparams, text, par, send);
627                         break;
628                 // Shouldn't happen
629                 case LATEX_BIB_ENVIRONMENT:
630                         send = par;
631                         ++send;
632                         par = makeParagraphs(buf, os, runparams, text, par, send);
633                         break;
634                 // Shouldn't happen
635                 case LATEX_COMMAND:
636                         ++par;
637                         break;
638                 }
639         }
640
641         if (lastlay != 0)
642                 closeItemTag(os, *lastlay);
643         if (main_tag_opened)
644                 closeTag(os, bstyle);
645         os << '\n';
646         return pend;
647 }
648
649
650 void makeCommand(Buffer const & buf,
651                                           odocstream & os,
652                                           OutputParams const & runparams,
653                                           Text const & text,
654                                           ParagraphList::const_iterator const & pbegin)
655 {
656         Layout const & style = pbegin->layout();
657         if (!style.counter.empty())
658                 buf.params().documentClass().counters().step(style.counter);
659
660         bool const main_tag_opened = openTag(os, style);
661
662         // Label around sectioning number:
663         // FIXME Probably need to account for LABEL_MANUAL
664         if (style.labeltype != LABEL_NO_LABEL) {
665                 bool const label_tag_opened = openLabelTag(os, style);
666                 os << pbegin->expandLabel(style, buf.params(), false);
667                 if (label_tag_opened)
668                         closeLabelTag(os, style);
669                 // Otherwise the label might run together with the text
670                 os << ' ';
671         }
672
673         ParagraphList::const_iterator const begin = text.paragraphs().begin();
674         pbegin->simpleLyXHTMLOnePar(buf, os, runparams,
675                         text.outerFont(distance(begin, pbegin)));
676         if (main_tag_opened)
677                 closeTag(os, style);
678         os << '\n';
679 }
680
681 } // end anonymous namespace
682
683
684 void xhtmlParagraphs(Text const & text,
685                        Buffer const & buf,
686                        odocstream & os,
687                        OutputParams const & runparams)
688 {
689         ParagraphList const & paragraphs = text.paragraphs();
690         ParagraphList::const_iterator par = paragraphs.begin();
691         ParagraphList::const_iterator pend = paragraphs.end();
692
693         OutputParams ourparams = runparams;
694         while (par != pend) {
695                 Layout const & style = par->layout();
696                 ParagraphList::const_iterator lastpar = par;
697                 ParagraphList::const_iterator send;
698
699                 switch (style.latextype) {
700                 case LATEX_COMMAND: {
701                         // The files with which we are working never have more than
702                         // one paragraph in a command structure.
703                         // FIXME 
704                         // if (ourparams.html_in_par)
705                         //   fix it so we don't get sections inside standard, e.g.
706                         // note that we may then need to make runparams not const, so we
707                         // can communicate that back.
708                         // FIXME Maybe this fix should be in the routines themselves, in case
709                         // they are called from elsewhere.
710                         makeCommand(buf, os, ourparams, text, par);
711                         ++par;
712                         break;
713                 }
714                 case LATEX_ENVIRONMENT:
715                 case LATEX_LIST_ENVIRONMENT:
716                 case LATEX_ITEM_ENVIRONMENT: {
717                         // FIXME Same fix here.
718                         send = searchEnvironmentHtml(par, pend);
719                         par = makeEnvironmentHtml(buf, os, ourparams, text, par, send);
720                         break;
721                 }
722                 case LATEX_BIB_ENVIRONMENT: {
723                         // FIXME Same fix here.
724                         send = searchEnvironmentHtml(par, pend);
725                         par = makeBibliography(buf, os, ourparams, text, par, send);
726                         break;
727                 }
728                 case LATEX_PARAGRAPH:
729                         send = searchParagraphHtml(par, pend);
730                         par = makeParagraphs(buf, os, ourparams, text, par, send);
731                         break;
732                 }
733                 // FIXME??
734                 // makeEnvironment may process more than one paragraphs and bypass pend
735                 if (distance(lastpar, par) >= distance(lastpar, pend))
736                         break;
737         }
738 }
739
740
741 } // namespace lyx