]> git.lyx.org Git - lyx.git/blob - src/output_xhtml.cpp
65acdb9387a48c39e1b0c52ffc16066a7e857199
[lyx.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 (html::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 (html::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_ << html::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 (html::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 (!html::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 namespace html {
319
320 ///////////////////////////////////////////////////////////////
321 // OLD STUFF to be replaced
322
323 // FIXME This needs to be protected somehow.
324 static vector<string> taglist;
325
326 bool openTag(odocstream & os, string const & tag, string const & attr)
327 {
328         if (tag.empty())
329                 return false;
330         os << from_ascii("<" + tag + (attr.empty() ? "" : " " + attr) + ">");
331         taglist.push_back(tag);
332         return true;
333 }
334
335
336 bool closeTag(odocstream & os, string const & tag)
337 {
338         if (tag.empty())
339                 return false;
340         // FIXME Check for proper nesting
341         if (taglist.empty()){
342                 LYXERR0("Last tag not found when closing `" << tag << "'!");
343                 return false;
344         }
345         string const & lasttag = taglist.back();
346         if (lasttag != tag)  {
347                 LYXERR0("Last tag was `" << lasttag << "' when closing `" << tag << "'!");
348                 return false;
349         }
350         taglist.pop_back();
351         os << from_ascii("</" + tag + ">");
352         return true;
353 }
354
355 } // html
356
357 namespace {
358
359 bool openTag(odocstream & os, Layout const & lay)
360 {
361         return html::openTag(os, lay.htmltag(), lay.htmlattr());
362 }
363
364
365 bool closeTag(odocstream & os, Layout const & lay)
366 {
367         return html::closeTag(os, lay.htmltag());
368 }
369
370
371 bool openLabelTag(odocstream & os, Layout const & lay)
372 {
373         return html::openTag(os, lay.htmllabeltag(), lay.htmllabelattr());
374 }
375
376
377 bool closeLabelTag(odocstream & os, Layout const & lay)
378 {
379         return html::closeTag(os, lay.htmllabeltag());
380 }
381
382
383 bool openItemTag(odocstream & os, Layout const & lay)
384 {
385         return html::openTag(os, lay.htmlitemtag(), lay.htmlitemattr());
386 }
387
388
389 bool closeItemTag(odocstream & os, Layout const & lay)
390 {
391         return html::closeTag(os, lay.htmlitemtag());
392 }
393
394 // end of old stuff to be replaced
395 ///////////////////////////////////////////////////////////////
396
397 ParagraphList::const_iterator searchParagraphHtml(
398         ParagraphList::const_iterator p,
399         ParagraphList::const_iterator const & pend)
400 {
401         for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p)
402                 ;
403
404         return p;
405 }
406
407
408 ParagraphList::const_iterator searchEnvironmentHtml(
409                 ParagraphList::const_iterator const pstart,
410                 ParagraphList::const_iterator const & pend)
411 {
412         ParagraphList::const_iterator p = pstart;
413         Layout const & bstyle = p->layout();
414         size_t const depth = p->params().depth();
415         for (++p; p != pend; ++p) {
416                 Layout const & style = p->layout();
417                 // It shouldn't happen that e.g. a section command occurs inside
418                 // a quotation environment, at a higher depth, but as of 6/2009,
419                 // it can happen. We pretend that it's just at lowest depth.
420                 if (style.latextype == LATEX_COMMAND)
421                         return p;
422                 // If depth is down, we're done
423                 if (p->params().depth() < depth)
424                         return p;
425                 // If depth is up, we're not done
426                 if (p->params().depth() > depth)
427                         continue;
428                 // Now we know we are at the same depth
429                 if (style.latextype == LATEX_PARAGRAPH
430                     || style.latexname() != bstyle.latexname())
431                         return p;
432         }
433         return pend;
434 }
435
436
437 ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
438                                             odocstream & os,
439                                             OutputParams const & runparams,
440                                             Text const & text,
441                                             ParagraphList::const_iterator const & pbegin,
442                                             ParagraphList::const_iterator const & pend)
443 {
444         ParagraphList::const_iterator const begin = text.paragraphs().begin();
445         ParagraphList::const_iterator par = pbegin;
446         for (; par != pend; ++par) {
447                 Layout const & lay = par->layout();
448                 if (!lay.counter.empty())
449                         buf.params().documentClass().counters().step(lay.counter);
450                 // FIXME We should see if there's a label to be output and
451                 // do something with it.
452                 if (par != pbegin)
453                         os << '\n';
454
455                 // FIXME Should we really allow anything other than 'p' here?
456                 
457                 // If we are already in a paragraph, and this is the first one, then we
458                 // do not want to open the paragraph tag.
459                 bool const opened = 
460                         (par == pbegin && runparams.html_in_par) ? false : openTag(os, lay);
461                 docstring const deferred = par->simpleLyXHTMLOnePar(buf, os, runparams,
462                                 text.outerFont(distance(begin, par)));
463
464                 // We want to issue the closing tag if either:
465                 //   (i)  We opened it, and either html_in_par is false,
466                 //        or we're not in the last paragraph, anyway.
467                 //   (ii) We didn't open it and html_in_par is true, 
468                 //        but we are in the first par, and there is a next par.
469                 ParagraphList::const_iterator nextpar = par;
470                 nextpar++;
471                 bool const needClose = 
472                         (opened && (!runparams.html_in_par || nextpar != pend))
473                         || (!opened && runparams.html_in_par && par == pbegin && nextpar != pend);
474                 if (needClose) {
475                         closeTag(os, lay);
476                         os << '\n';
477                 }
478                 if (!deferred.empty())
479                         os << deferred << '\n';
480         }
481         return pend;
482 }
483
484
485 ParagraphList::const_iterator makeBibliography(Buffer const & buf,
486                                 odocstream & os,
487                                 OutputParams const & runparams,
488                                 Text const & text,
489                                 ParagraphList::const_iterator const & pbegin,
490                                 ParagraphList::const_iterator const & pend) 
491 {
492         os << "<h2 class='bibliography'>" 
493            << pbegin->layout().labelstring(false) 
494            << "</h2>\n"
495            << "<div class='bibliography'>\n";
496                         makeParagraphs(buf, os, runparams, text, pbegin, pend);
497         os << "</div>";
498         return pend;
499 }
500
501
502 bool isNormalEnv(Layout const & lay)
503 {
504         return lay.latextype == LATEX_ENVIRONMENT;
505 }
506
507         
508 ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
509                                               odocstream & os,
510                                               OutputParams const & runparams,
511                                               Text const & text,
512                                               ParagraphList::const_iterator const & pbegin,
513                                               ParagraphList::const_iterator const & pend) 
514 {
515         ParagraphList::const_iterator const begin = text.paragraphs().begin();
516         ParagraphList::const_iterator par = pbegin;
517         Layout const & bstyle = par->layout();
518         depth_type const origdepth = pbegin->params().depth();
519
520         // Open tag for this environment
521         bool const main_tag_opened = openTag(os, bstyle);
522         os << '\n';
523
524         // we will on occasion need to remember a layout from before.
525         Layout const * lastlay = 0;
526
527         while (par != pend) {
528                 Layout const & style = par->layout();
529                 // the counter only gets stepped if we're in some kind of list,
530                 // or if it's the first time through.
531                 if (!style.counter.empty() && (par == pbegin || !isNormalEnv(style)))
532                         buf.params().documentClass().counters().step(style.counter);
533                 ParagraphList::const_iterator send;
534                 // this will be positive, if we want to skip the initial word
535                 // (if it's been taken for the label).
536                 pos_type sep = 0;
537
538                 switch (style.latextype) {
539                 case LATEX_ENVIRONMENT:
540                 case LATEX_LIST_ENVIRONMENT:
541                 case LATEX_ITEM_ENVIRONMENT: {
542                         // There are two possiblities in this case. 
543                         // One is that we are still in the environment in which we 
544                         // started---which we will be if the depth is the same.
545                         if (par->params().depth() == origdepth) {
546                                 LASSERT(bstyle == style, /* */);
547                                 if (lastlay != 0) {
548                                         closeItemTag(os, *lastlay);
549                                         lastlay = 0;
550                                 }
551                                 bool item_tag_opened = false;
552                                 bool const labelfirst = style.htmllabelfirst();
553                                 bool madelabel = false;
554                                 if (isNormalEnv(style)) {
555                                         // in this case, we print the label only for the first 
556                                         // paragraph (as in a theorem).
557                                         item_tag_opened = openItemTag(os, style);
558                                         if (par == pbegin && style.htmllabeltag() != "NONE") {
559                                                 docstring const lbl = 
560                                                                 pbegin->expandLabel(style, buf.params(), false);
561                                                 if (!lbl.empty()) {
562                                                         bool const label_tag_opened = openLabelTag(os, style);
563                                                         os << lbl;
564                                                         if (label_tag_opened)
565                                                                 closeLabelTag(os, style);
566                                                 }
567                                                 os << '\n';
568                                         }
569                                 }       else { // some kind of list
570                                         if (!labelfirst)
571                                                 item_tag_opened = openItemTag(os, style);
572                                         if (style.labeltype == LABEL_MANUAL
573                                             && style.htmllabeltag() != "NONE") {
574                                                 madelabel = openLabelTag(os, style);
575                                                 sep = par->firstWordLyXHTML(os, runparams);
576                                                 if (madelabel)
577                                                         closeLabelTag(os, style);
578                                                 os << '\n';
579                                         }
580                                         else if (style.labeltype != LABEL_NO_LABEL
581                                                  && style.htmllabeltag() != "NONE") {
582                                                 madelabel = openLabelTag(os, style);
583                                                 os << par->expandLabel(style, buf.params(), false);
584                                                 if (madelabel)
585                                                         closeLabelTag(os, style);
586                                                 os << '\n';
587                                         }
588                                         if (labelfirst)
589                                                 item_tag_opened = openItemTag(os, style);
590                                         else if (madelabel)
591                                                 os << "<span class='" << style.name() << "inneritem'>";
592                                 }
593                                 par->simpleLyXHTMLOnePar(buf, os, runparams, 
594                                         text.outerFont(distance(begin, par)), sep);
595                                 if (!isNormalEnv(style) && !labelfirst && madelabel)
596                                         os << "</span>";
597                                 ++par;
598                                 if (item_tag_opened) {
599                                         // We may not want to close the tag yet, in particular,
600                                         // if we're not at the end...
601                                         if (par != pend 
602                                     //  and are doing items...
603                                      && style.latextype == LATEX_ITEM_ENVIRONMENT
604                                      // and if the depth has changed...
605                                      && par->params().depth() != origdepth) {
606                                      // then we'll save this layout for later, and close it when
607                                      // we get another item.
608                                                 lastlay = &style;
609                                         } else
610                                                 closeItemTag(os, style);
611                                         os << '\n';
612                                 }
613                         }
614                         // The other possibility is that the depth has increased, in which
615                         // case we need to recurse.
616                         else {
617                                 send = searchEnvironmentHtml(par, pend);
618                                 par = makeEnvironmentHtml(buf, os, runparams, text, par, send);
619                         }
620                         break;
621                 }
622                 case LATEX_PARAGRAPH:
623                         send = searchParagraphHtml(par, pend);
624                         par = makeParagraphs(buf, os, runparams, text, par, send);
625                         break;
626                 // Shouldn't happen
627                 case LATEX_BIB_ENVIRONMENT:
628                         send = par;
629                         ++send;
630                         par = makeParagraphs(buf, os, runparams, text, par, send);
631                         break;
632                 // Shouldn't happen
633                 case LATEX_COMMAND:
634                         ++par;
635                         break;
636                 }
637         }
638
639         if (lastlay != 0)
640                 closeItemTag(os, *lastlay);
641         if (main_tag_opened)
642                 closeTag(os, bstyle);
643         os << '\n';
644         return pend;
645 }
646
647
648 void makeCommand(Buffer const & buf,
649                                           odocstream & os,
650                                           OutputParams const & runparams,
651                                           Text const & text,
652                                           ParagraphList::const_iterator const & pbegin)
653 {
654         Layout const & style = pbegin->layout();
655         if (!style.counter.empty())
656                 buf.params().documentClass().counters().step(style.counter);
657
658         bool const main_tag_opened = openTag(os, style);
659
660         // Label around sectioning number:
661         // FIXME Probably need to account for LABEL_MANUAL
662         if (style.labeltype != LABEL_NO_LABEL) {
663                 bool const label_tag_opened = openLabelTag(os, style);
664                 os << pbegin->expandLabel(style, buf.params(), false);
665                 if (label_tag_opened)
666                         closeLabelTag(os, style);
667                 // Otherwise the label might run together with the text
668                 os << ' ';
669         }
670
671         ParagraphList::const_iterator const begin = text.paragraphs().begin();
672         pbegin->simpleLyXHTMLOnePar(buf, os, runparams,
673                         text.outerFont(distance(begin, pbegin)));
674         if (main_tag_opened)
675                 closeTag(os, style);
676         os << '\n';
677 }
678
679 } // end anonymous namespace
680
681
682 void xhtmlParagraphs(Text const & text,
683                        Buffer const & buf,
684                        odocstream & os,
685                        OutputParams const & runparams)
686 {
687         ParagraphList const & paragraphs = text.paragraphs();
688         ParagraphList::const_iterator par = paragraphs.begin();
689         ParagraphList::const_iterator pend = paragraphs.end();
690
691         OutputParams ourparams = runparams;
692         while (par != pend) {
693                 Layout const & style = par->layout();
694                 ParagraphList::const_iterator lastpar = par;
695                 ParagraphList::const_iterator send;
696
697                 switch (style.latextype) {
698                 case LATEX_COMMAND: {
699                         // The files with which we are working never have more than
700                         // one paragraph in a command structure.
701                         // FIXME 
702                         // if (ourparams.html_in_par)
703                         //   fix it so we don't get sections inside standard, e.g.
704                         // note that we may then need to make runparams not const, so we
705                         // can communicate that back.
706                         // FIXME Maybe this fix should be in the routines themselves, in case
707                         // they are called from elsewhere.
708                         makeCommand(buf, os, ourparams, text, par);
709                         ++par;
710                         break;
711                 }
712                 case LATEX_ENVIRONMENT:
713                 case LATEX_LIST_ENVIRONMENT:
714                 case LATEX_ITEM_ENVIRONMENT: {
715                         // FIXME Same fix here.
716                         send = searchEnvironmentHtml(par, pend);
717                         par = makeEnvironmentHtml(buf, os, ourparams, text, par, send);
718                         break;
719                 }
720                 case LATEX_BIB_ENVIRONMENT: {
721                         // FIXME Same fix here.
722                         send = searchEnvironmentHtml(par, pend);
723                         par = makeBibliography(buf, os, ourparams, text, par, send);
724                         break;
725                 }
726                 case LATEX_PARAGRAPH:
727                         send = searchParagraphHtml(par, pend);
728                         par = makeParagraphs(buf, os, ourparams, text, par, send);
729                         break;
730                 }
731                 // FIXME??
732                 // makeEnvironment may process more than one paragraphs and bypass pend
733                 if (distance(lastpar, par) >= distance(lastpar, pend))
734                         break;
735         }
736 }
737
738
739 } // namespace lyx