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