2 * \file paragraph_funcs.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS
13 #include "paragraph_funcs.h"
14 #include "paragraph_pimpl.h"
16 #include "ParagraphParameters.h"
17 #include "lyxtextclasslist.h"
24 #include "BoostFormat.h"
26 #include "support/lstrings.h"
27 #include "insets/insetoptarg.h"
28 #include "insets/insetcommandparams.h"
29 #include "insets/insetbibitem.h"
30 #include "insets/insetspecialchar.h"
31 #include "insets/insetlatexaccent.h"
32 #include "insets/insettabular.h"
33 #include "insets/insethfill.h"
34 #include "insets/inseterror.h"
35 #include "insets/insetnewline.h"
37 extern string bibitemWidest(Buffer const *);
40 //using lyx::layout_type;
44 void breakParagraph(BufferParams const & bparams,
45 ParagraphList & paragraphs,
46 ParagraphList::iterator par,
50 // create a new paragraph, and insert into the list
51 ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
54 // without doing that we get a crash when typing <Return> at the
56 tmp->layout(bparams.getLyXTextClass().defaultLayout());
57 // remember to set the inset_owner
58 tmp->setInsetOwner(par->inInset());
60 if (bparams.tracking_changes)
63 // this is an idea for a more userfriendly layout handling, I will
64 // see what the users say
66 // layout stays the same with latex-environments
68 tmp->layout(par->layout());
69 tmp->setLabelWidthString(par->params().labelWidthString());
72 bool const isempty = (par->layout()->keepempty && par->empty());
74 if (!isempty && (par->size() > pos || par->empty() || flag == 2)) {
75 tmp->layout(par->layout());
76 tmp->params().align(par->params().align());
77 tmp->setLabelWidthString(par->params().labelWidthString());
79 tmp->params().lineBottom(par->params().lineBottom());
80 par->params().lineBottom(false);
81 tmp->params().pagebreakBottom(par->params().pagebreakBottom());
82 par->params().pagebreakBottom(false);
83 tmp->params().spaceBottom(par->params().spaceBottom());
84 par->params().spaceBottom(VSpace(VSpace::NONE));
86 tmp->params().depth(par->params().depth());
87 tmp->params().noindent(par->params().noindent());
89 // copy everything behind the break-position
90 // to the new paragraph
93 #warning this seems wrong
95 /* FIXME: if !keepempty, empty() == true, then we reach
96 * here with size() == 0. So pos_end becomes - 1. Why
97 * doesn't this cause problems ???
99 pos_type pos_end = par->size() - 1;
103 for (; i <= pos_end; ++i) {
104 Change::Type change(par->lookupChange(i));
105 par->cutIntoMinibuffer(bparams, i);
106 if (tmp->insertFromMinibuffer(j - pos)) {
107 tmp->setChange(j - pos, change);
111 for (i = pos_end; i >= pos; --i) {
119 tmp->params().lineTop(par->params().lineTop());
120 tmp->params().pagebreakTop(par->params().pagebreakTop());
121 tmp->params().spaceTop(par->params().spaceTop());
122 par->params().clear();
124 par->layout(bparams.getLyXTextClass().defaultLayout());
126 // layout stays the same with latex-environments
128 par->layout(tmp->layout());
129 par->setLabelWidthString(tmp->params().labelWidthString());
130 par->params().depth(tmp->params().depth());
133 // subtle, but needed to get empty pars working right
134 if (bparams.tracking_changes) {
137 } else if (!tmp->size()) {
144 void breakParagraphConservative(BufferParams const & bparams,
145 ParagraphList & paragraphs,
146 ParagraphList::iterator par,
149 // create a new paragraph
150 ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
152 tmp->makeSameLayout(&*par);
154 // When can pos > Last()?
155 // I guess pos == Last() is possible.
156 if (par->size() > pos) {
157 // copy everything behind the break-position to the new
159 pos_type pos_end = par->size() - 1;
161 for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
162 par->cutIntoMinibuffer(bparams, i);
163 if (tmp->insertFromMinibuffer(j - pos))
167 for (pos_type k = pos_end; k >= pos; --k) {
174 void mergeParagraph(BufferParams const & bparams,
175 ParagraphList & paragraphs,
176 ParagraphList::iterator par)
178 ParagraphList::iterator the_next = boost::next(par);
180 // first the DTP-stuff
181 par->params().lineBottom(the_next->params().lineBottom());
182 par->params().spaceBottom(the_next->params().spaceBottom());
183 par->params().pagebreakBottom(the_next->params().pagebreakBottom());
185 pos_type pos_end = the_next->size() - 1;
186 pos_type pos_insert = par->size();
188 // ok, now copy the paragraph
189 for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
190 the_next->cutIntoMinibuffer(bparams, i);
191 if (par->insertFromMinibuffer(pos_insert + j))
195 paragraphs.erase(the_next);
200 Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth)
202 Paragraph * newpar = par;
205 newpar = newpar->previous();
206 } while (newpar && newpar->getDepth() > depth);
209 if (par->previous() || par->getDepth())
210 lyxerr << "Error (depthHook): "
211 << "no hook." << endl;
218 Paragraph * outerHook(Paragraph * par)
220 if (!par->getDepth())
222 return depthHook(par, Paragraph::depth_type(par->getDepth() - 1));
226 bool isFirstInSequence(Paragraph * par)
228 Paragraph const * dhook = depthHook(par, par->getDepth());
230 || dhook->getLayout() != par->getLayout()
231 || dhook->getDepth() != par->getDepth());
235 int getEndLabel(Paragraph * para, BufferParams const & bparams)
237 Paragraph * par = para;
239 Paragraph::depth_type par_depth = par->getDepth();
240 layout_type layout = par->getLayout();
241 int const endlabeltype =
242 textclasslist.Style(bparams.textclass,
243 layout).endlabeltype;
244 if (endlabeltype != END_LABEL_NO_LABEL) {
248 Paragraph::depth_type const next_depth =
249 para->next()->getDepth();
250 if (par_depth > next_depth ||
251 (par_depth == next_depth
252 && layout != para->next()->getLayout()))
258 par = outerHook(par);
260 return END_LABEL_NO_LABEL;
265 ParagraphList::iterator
266 TeXDeeper(Buffer const * buf,
267 BufferParams const & bparams,
268 ParagraphList const & paragraphs,
269 ParagraphList::iterator pit,
270 ostream & os, TexRow & texrow)
272 lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
273 ParagraphList::iterator par = pit;
275 while (par != paragraphs.end()&& par->params().depth() == pit->params().depth()) {
276 if (par->layout()->isEnvironment()) {
277 par = TeXEnvironment(buf, bparams, paragraphs, par,
280 par = TeXOnePar(buf, bparams, paragraphs, par,
284 lyxerr[Debug::LATEX] << "TeXDeeper...done " << &*par << endl;
290 ParagraphList::iterator
291 TeXEnvironment(Buffer const * buf,
292 BufferParams const & bparams,
293 ParagraphList const & paragraphs,
294 ParagraphList::iterator pit,
295 ostream & os, TexRow & texrow)
297 lyxerr[Debug::LATEX] << "TeXEnvironment... " << &*pit << endl;
299 LyXLayout_ptr const & style = pit->layout();
301 Language const * language = pit->getParLanguage(bparams);
302 Language const * doc_language = bparams.language;
303 Language const * previous_language =
304 (pit != paragraphs.begin())
305 ? boost::prior(pit)->getParLanguage(bparams)
307 if (language->babel() != previous_language->babel()) {
309 if (!lyxrc.language_command_end.empty() &&
310 previous_language->babel() != doc_language->babel()) {
311 os << subst(lyxrc.language_command_end, "$$lang",
312 previous_language->babel())
317 if (lyxrc.language_command_end.empty() ||
318 language->babel() != doc_language->babel()) {
319 os << subst(lyxrc.language_command_begin, "$$lang",
326 bool leftindent_open = false;
327 if (!pit->params().leftIndent().zero()) {
328 os << "\\begin{LyXParagraphLeftIndent}{" <<
329 pit->params().leftIndent().asLatexString() << "}\n";
331 leftindent_open = true;
334 if (style->isEnvironment()) {
335 if (style->latextype == LATEX_LIST_ENVIRONMENT) {
336 os << "\\begin{" << style->latexname() << "}{"
337 << pit->params().labelWidthString() << "}\n";
338 } else if (style->labeltype == LABEL_BIBLIO) {
340 os << "\\begin{" << style->latexname() << "}{"
341 << bibitemWidest(buf)
343 } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
344 os << "\\begin{" << style->latexname() << '}'
345 << style->latexparam() << '\n';
347 os << "\\begin{" << style->latexname() << '}'
348 << style->latexparam() << '\n';
351 ParagraphList::iterator par = pit;
353 par = TeXOnePar(buf, bparams, paragraphs, par, os, texrow, false);
355 if (par != paragraphs.end()&& par->params().depth() > pit->params().depth()) {
356 if (par->layout()->isParagraph()) {
359 // How to handle this? (Lgb)
360 //&& !suffixIs(os, "\n\n")
362 // There should be at least one '\n' already
363 // but we need there to be two for Standard
364 // paragraphs that are depth-increment'ed to be
365 // output correctly. However, tables can
366 // also be paragraphs so don't adjust them.
369 // Will it ever harm to have one '\n' too
370 // many? i.e. that we sometimes will have
371 // three in a row. (Lgb)
375 par = TeXDeeper(buf, bparams, paragraphs, par, os, texrow);
377 } while (par != paragraphs.end()
378 && par->layout() == pit->layout()
379 && par->params().depth() == pit->params().depth()
380 && par->params().leftIndent() == pit->params().leftIndent());
382 if (style->isEnvironment()) {
383 os << "\\end{" << style->latexname() << "}\n";
387 if (leftindent_open) {
388 os << "\\end{LyXParagraphLeftIndent}\n";
392 lyxerr[Debug::LATEX] << "TeXEnvironment...done " << &*par << endl;
393 return par; // ale970302
399 InsetOptArg * optArgInset(Paragraph const & par)
402 InsetList::iterator it = par.insetlist.begin();
403 InsetList::iterator end = par.insetlist.end();
404 for (; it != end; ++it) {
405 Inset * ins = it.getInset();
406 if (ins->lyxCode() == Inset::OPTARG_CODE) {
407 return static_cast<InsetOptArg *>(ins);
416 ParagraphList::iterator
417 TeXOnePar(Buffer const * buf,
418 BufferParams const & bparams,
419 ParagraphList const & paragraphs,
420 ParagraphList::iterator pit,
421 ostream & os, TexRow & texrow,
424 lyxerr[Debug::LATEX] << "TeXOnePar... " << &*pit << endl;
425 Inset const * in = pit->inInset();
426 bool further_blank_line = false;
429 // well we have to check if we are in an inset with unlimited
430 // lenght (all in one row) if that is true then we don't allow
431 // any special options in the paragraph and also we don't allow
432 // any environment other then "Standard" to be valid!
433 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
434 style = pit->layout();
436 if (pit->params().startOfAppendix()) {
437 os << "\\appendix\n";
441 if (!pit->params().spacing().isDefault()
442 && (pit == paragraphs.begin() || !boost::prior(pit)->hasSameLayout(&*pit))) {
443 os << pit->params().spacing().writeEnvirBegin() << '\n';
447 if (style->isCommand()) {
452 if (pit->params().pagebreakTop()) {
454 further_blank_line = true;
456 if (pit->params().spaceTop().kind() != VSpace::NONE) {
457 os << pit->params().spaceTop().asLatexCommand(bparams);
458 further_blank_line = true;
461 if (pit->params().lineTop()) {
462 os << "\\lyxline{\\" << pit->getFont(bparams, 0).latexSize() << '}'
463 << "\\vspace{-1\\parskip}";
464 further_blank_line = true;
467 if (further_blank_line) {
472 style = bparams.getLyXTextClass().defaultLayout();
475 Language const * language = pit->getParLanguage(bparams);
476 Language const * doc_language = bparams.language;
477 Language const * previous_language =
478 (pit != paragraphs.begin())
479 ? boost::prior(pit)->getParLanguage(bparams)
482 if (language->babel() != previous_language->babel()
483 // check if we already put language command in TeXEnvironment()
484 && !(style->isEnvironment()
485 && (pit == paragraphs.begin() ||
486 (boost::prior(pit)->layout() != pit->layout() &&
487 boost::prior(pit)->getDepth() <= pit->getDepth())
488 || boost::prior(pit)->getDepth() < pit->getDepth())))
490 if (!lyxrc.language_command_end.empty() &&
491 previous_language->babel() != doc_language->babel())
493 os << subst(lyxrc.language_command_end, "$$lang",
494 previous_language->babel())
499 if (lyxrc.language_command_end.empty() ||
500 language->babel() != doc_language->babel())
502 os << subst(lyxrc.language_command_begin, "$$lang",
509 if (bparams.inputenc == "auto" &&
510 language->encoding() != previous_language->encoding()) {
511 os << "\\inputencoding{"
512 << language->encoding()->LatexName()
517 switch (style->latextype) {
519 os << '\\' << style->latexname();
521 // Separate handling of optional argument inset.
522 if (style->optionalargs == 1) {
523 InsetOptArg * it = optArgInset(*pit);
525 it->latexOptional(buf, os, false, false);
528 os << style->latexparam();
530 case LATEX_ITEM_ENVIRONMENT:
531 case LATEX_LIST_ENVIRONMENT:
534 case LATEX_BIB_ENVIRONMENT:
535 // ignore this, the inset will write itself
541 bool need_par = pit->simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
543 // Make sure that \\par is done with the font of the last
544 // character if this has another size as the default.
545 // This is necessary because LaTeX (and LyX on the screen)
546 // calculates the space between the baselines according
547 // to this font. (Matthias)
549 // Is this really needed ? (Dekel)
550 // We do not need to use to change the font for the last paragraph
554 ? pit->getLayoutFont(bparams) : pit->getFont(bparams, pit->size() - 1));
556 bool is_command = style->isCommand();
558 if (style->resfont.size() != font.size()
559 && boost::next(pit) != paragraphs.end()
563 os << "\\" << font.latexSize() << " \\par}";
564 } else if (need_par) {
566 } else if (is_command)
569 switch (style->latextype) {
570 case LATEX_ITEM_ENVIRONMENT:
571 case LATEX_LIST_ENVIRONMENT:
572 if (boost::next(pit) != paragraphs.end()
573 && (pit->params().depth() < boost::next(pit)->params().depth())) {
578 case LATEX_ENVIRONMENT:
579 // if its the last paragraph of the current environment
580 // skip it otherwise fall through
581 if (boost::next(pit) != paragraphs.end()
582 && (boost::next(pit)->layout() != pit->layout()
583 || boost::next(pit)->params().depth() != pit->params().depth()))
585 // fall through possible
587 // we don't need it for the last paragraph!!!
588 if (boost::next(pit) != paragraphs.end()) {
594 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
595 further_blank_line = false;
596 if (pit->params().lineBottom()) {
597 os << "\\lyxline{\\" << font.latexSize() << '}';
598 further_blank_line = true;
601 if (pit->params().spaceBottom().kind() != VSpace::NONE) {
602 os << pit->params().spaceBottom().asLatexCommand(bparams);
603 further_blank_line = true;
606 if (pit->params().pagebreakBottom()) {
608 further_blank_line = true;
611 if (further_blank_line) {
616 if (!pit->params().spacing().isDefault()
617 && (boost::next(pit) == paragraphs.end()|| !boost::next(pit)->hasSameLayout(&*pit))) {
618 os << pit->params().spacing().writeEnvirEnd() << '\n';
623 // we don't need it for the last paragraph!!!
624 if (boost::next(pit) != paragraphs.end()) {
628 // Since \selectlanguage write the language to the aux file,
629 // we need to reset the language at the end of footnote or
632 if (language->babel() != doc_language->babel()) {
633 if (lyxrc.language_command_end.empty())
634 os << subst(lyxrc.language_command_begin,
636 doc_language->babel())
639 os << subst(lyxrc.language_command_end,
647 lyxerr[Debug::LATEX] << "TeXOnePar...done " << &*boost::next(pit) << endl;
653 // LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end
655 void latexParagraphs(Buffer const * buf,
656 ParagraphList const & paragraphs,
657 ParagraphList::iterator par,
658 ParagraphList::iterator endpar,
663 bool was_title = false;
664 bool already_title = false;
665 LyXTextClass const & tclass = buf->params.getLyXTextClass();
668 while (par != endpar) {
669 Inset * in = par->inInset();
670 // well we have to check if we are in an inset with unlimited
671 // length (all in one row) if that is true then we don't allow
672 // any special options in the paragraph and also we don't allow
673 // any environment other then "Standard" to be valid!
674 if ((in == 0) || !in->forceDefaultParagraphs(in)) {
675 LyXLayout_ptr const & layout = par->layout();
677 if (layout->intitle) {
679 lyxerr <<"Error in latexParagraphs: You"
680 " should not mix title layouts"
681 " with normal ones." << endl;
682 } else if (!was_title) {
684 if (tclass.titletype() == TITLE_ENVIRONMENT) {
686 << tclass.titlename()
691 } else if (was_title && !already_title) {
692 if (tclass.titletype() == TITLE_ENVIRONMENT) {
693 ofs << "\\end{" << tclass.titlename()
697 ofs << "\\" << tclass.titlename()
701 already_title = true;
705 if (layout->isEnvironment() ||
706 !par->params().leftIndent().zero())
708 par = TeXEnvironment(buf, buf->params, paragraphs, par, ofs, texrow);
710 par = TeXOnePar(buf, buf->params, paragraphs, par, ofs, texrow, moving_arg);
713 par = TeXOnePar(buf, buf->params, paragraphs, par, ofs, texrow, moving_arg);
716 // It might be that we only have a title in this document
717 if (was_title && !already_title) {
718 if (tclass.titletype() == TITLE_ENVIRONMENT) {
719 ofs << "\\end{" << tclass.titlename()
723 ofs << "\\" << tclass.titlename()
733 int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & token)
736 static Change change;
738 BufferParams const & bp = buf.params;
740 if (token[0] != '\\') {
741 string::const_iterator cit = token.begin();
742 for (; cit != token.end(); ++cit) {
743 par.insertChar(par.size(), (*cit), font, change);
745 } else if (token == "\\layout") {
747 string layoutname = lex.getString();
749 font = LyXFont(LyXFont::ALL_INHERIT, bp.language);
752 LyXTextClass const & tclass = bp.getLyXTextClass();
754 if (layoutname.empty()) {
755 layoutname = tclass.defaultLayoutName();
758 bool hasLayout = tclass.hasLayout(layoutname);
761 lyxerr << "Layout '" << layoutname << "' does not"
762 << " exist in textclass '" << tclass.name()
764 lyxerr << "Trying to use default layout instead."
766 layoutname = tclass.defaultLayoutName();
770 // The is the compability reading of layout caption.
771 if (compare_ascii_no_case(layoutname, "caption") == 0) {
772 // We expect that the par we are now working on is
773 // really inside a InsetText inside a InsetFloat.
774 // We also know that captions can only be
775 // one paragraph. (Lgb)
777 // We should now read until the next "\layout"
779 // This is probably not good enough, what if the
780 // caption is the last par in the document (Lgb)
781 istream & ist = lex.getStream();
787 if (prefixIs(line, "\\layout")) {
791 if (prefixIs(line, "\\begin_inset"))
793 if (prefixIs(line, "\\end_inset")) {
805 // Now we should have the whole layout in ss
806 // we should now be able to give this to the
808 ss << "\\end_inset\n";
810 // This seems like a bug in stringstream.
811 // We really should be able to use ss
813 istringstream is(ss.str());
815 tmplex.setStream(is);
816 Inset * inset = new InsetCaption;
817 inset->Read(this, tmplex);
818 par.insertInset(pos, inset, font);
822 par.layout(bp.getLyXTextClass()[layoutname]);
824 // Test whether the layout is obsolete.
825 LyXLayout_ptr const & layout = par.layout();
826 if (!layout->obsoleted_by().empty())
827 par.layout(bp.getLyXTextClass()[layout->obsoleted_by()]);
829 par.params().read(lex);
834 } else if (token == "\\end_inset") {
835 lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n"
836 << "Missing \\begin_inset?.\n";
837 // Simply ignore this. The insets do not have
839 // But insets should read it, it is a part of
840 // the inset isn't it? Lgb.
841 } else if (token == "\\begin_inset") {
842 Inset * i = readInset(lex, buf);
843 par.insertInset(par.size(), i, font, change);
844 } else if (token == "\\family") {
846 font.setLyXFamily(lex.getString());
847 } else if (token == "\\series") {
849 font.setLyXSeries(lex.getString());
850 } else if (token == "\\shape") {
852 font.setLyXShape(lex.getString());
853 } else if (token == "\\size") {
855 font.setLyXSize(lex.getString());
856 } else if (token == "\\lang") {
858 string const tok = lex.getString();
859 Language const * lang = languages.getLanguage(tok);
861 font.setLanguage(lang);
863 font.setLanguage(bp.language);
864 lex.printError("Unknown language `$$Token'");
866 } else if (token == "\\numeric") {
868 font.setNumber(font.setLyXMisc(lex.getString()));
869 } else if (token == "\\emph") {
871 font.setEmph(font.setLyXMisc(lex.getString()));
872 } else if (token == "\\bar") {
874 string const tok = lex.getString();
877 font.setUnderbar(LyXFont::ON);
878 else if (tok == "no")
879 font.setUnderbar(LyXFont::OFF);
880 else if (tok == "default")
881 font.setUnderbar(LyXFont::INHERIT);
883 lex.printError("Unknown bar font flag "
885 } else if (token == "\\noun") {
887 font.setNoun(font.setLyXMisc(lex.getString()));
888 } else if (token == "\\color") {
890 font.setLyXColor(lex.getString());
891 } else if (token == "\\SpecialChar") {
892 LyXLayout_ptr const & layout = par.layout();
894 // Insets don't make sense in a free-spacing context! ---Kayvan
895 if (layout->free_spacing || par.isFreeSpacing()) {
898 string const next_token = lex.getString();
899 if (next_token == "\\-") {
900 par.insertChar(par.size(), '-', font, change);
901 } else if (next_token == "~") {
902 par.insertChar(par.size(), ' ', font, change);
904 lex.printError("Token `$$Token' "
906 "paragraph layout!");
910 Inset * inset = new InsetSpecialChar;
911 inset->read(&buf, lex);
912 par.insertInset(par.size(), inset, font, change);
914 } else if (token == "\\i") {
915 Inset * inset = new InsetLatexAccent;
916 inset->read(&buf, lex);
917 par.insertInset(par.size(), inset, font, change);
918 } else if (token == "\\backslash") {
919 par.insertChar(par.size(), '\\', font, change);
920 } else if (token == "\\newline") {
921 Inset * inset = new InsetNewline;
922 inset->read(&buf, lex);
923 par.insertInset(par.size(), inset, font, change);
924 } else if (token == "\\LyXTable") {
925 Inset * inset = new InsetTabular(buf);
926 inset->read(&buf, lex);
927 par.insertInset(par.size(), inset, font, change);
928 } else if (token == "\\bibitem") {
929 InsetCommandParams p("bibitem", "dummy");
930 InsetBibitem * inset = new InsetBibitem(p);
931 inset->read(&buf, lex);
932 par.insertInset(par.size(), inset, font, change);
933 } else if (token == "\\hfill") {
934 par.insertInset(par.size(), new InsetHFill(), font, change);
935 } else if (token == "\\change_unchanged") {
936 // Hack ! Needed for empty paragraphs :/
937 // FIXME: is it still ??
940 change = Change(Change::UNCHANGED);
941 } else if (token == "\\change_inserted") {
943 istringstream istr(lex.getString());
948 change = Change(Change::INSERTED, bp.author_map[aid], ct);
949 } else if (token == "\\change_deleted") {
951 istringstream istr(lex.getString());
956 change = Change(Change::DELETED, bp.author_map[aid], ct);
960 boost::format fmt(_("Unknown token: %1$s %2$s\n"));
961 fmt % token % lex.text();
962 string const s = fmt.str();
964 string const s = _("Unknown token: ") + token
965 + ' ' + lex.text() + '\n';
967 // we can do this here this way because we're actually reading
968 // the buffer and don't care about LyXText right now.
969 InsetError * inset = new InsetError(s);
970 par.insertInset(par.size(), inset, font);
979 int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex)
984 string token = lex.getString();
988 unknown += readParToken(buf, par, lex, token);
991 token = lex.getString();
996 lyxerr[Debug::PARSER] << "Handling paragraph token: `"
997 << token << '\'' << endl;
999 // reached the next paragraph. FIXME: really we should
1000 // change the file format to indicate the end of a par
1001 // clearly, but for now, this hack will do
1002 if (token == "\\layout" || token == "\\the_end"
1003 || token == "\\end_inset" || token == "\\begin_deeper"
1004 || token == "\\end_deeper") {
1005 lex.pushToken(token);