TeXFont const & font_)
: need_layout(need_layout_),
need_end_layout(false), need_end_deeper(false),
- has_item(false), deeper_paragraph(false),
+ has_item(false), in_list_preamble(false), deeper_paragraph(false),
new_layout_allowed(true), merging_hyphens_allowed(true),
textclass(textclass_),
layout(layout_), parent_layout(parent_layout_),
std::string par_extra_stuff;
/// We may need to add something at the beginning of a list.
std::string list_extra_stuff;
+ /// Stuff between list begin and first item
+ std::string list_preamble;
/// A LaTeXParam to be ignored in parsing.
std::string latexparam;
/// If there has been an \\begin_deeper, we'll need a matching
/// for each paragraph, otherwise this has to be a deeper
/// paragraph.
bool has_item;
+ /// If we are in an itemize-like environment, this marks
+ /// the text before the first \item. Typically, list
+ /// parameters (such as lengths) are adjusted here.
+ bool in_list_preamble;
/// we are handling a standard paragraph in an itemize-like
/// environment
bool deeper_paragraph;
}
switch (context.layout->latextype) {
case LATEX_LIST_ENVIRONMENT:
+ context.in_list_preamble =
+ !context.layout->listpreamble().empty()
+ && p.hasListPreamble(context.layout->itemcommand());
context.add_par_extra_stuff("\\labelwidthstring "
+ p.verbatim_item() + '\n');
p.skip_spaces();
output_arguments(os, p, outer, false, string(), context,
context.layout->latexargs());
else if (context.layout->latextype == LATEX_ITEM_ENVIRONMENT) {
+ context.in_list_preamble =
+ !context.layout->listpreamble().empty()
+ && p.hasListPreamble(context.layout->itemcommand());
ostringstream oss;
output_arguments(oss, p, outer, false, string(), context,
context.layout->latexargs());
context.list_extra_stuff = oss.str();
}
+ if (context.in_list_preamble) {
+ // Collect the stuff between \begin and first \item
+ context.list_preamble =
+ parse_text_snippet(p, FLAG_END, outer, context);
+ context.in_list_preamble = false;
+ }
parse_text(p, os, FLAG_END, outer, context);
if (context.layout->latextype == LATEX_ENVIRONMENT)
output_arguments(os, p, outer, false, "post", context,
debugToken(cerr, t, flags);
#endif
+ if (context.in_list_preamble
+ && p.next_token().cs() == context.layout->itemcommand()) {
+ // We are parsing a list preamble. End before first \item.
+ flags |= FLAG_LEAVE;
+ context.in_list_preamble = false;
+ }
+
if (flags & FLAG_ITEM) {
if (t.cat() == catSpace)
continue;
if (context.layout->labeltype != LABEL_MANUAL)
output_arguments(os, p, outer, false, "item", context,
context.layout->itemargs());
+ if (!context.list_preamble.empty()) {
+ // We have a list preamble. Output it here.
+ begin_inset(os, "Argument listpreamble:1");
+ os << "\nstatus collapsed\n\n"
+ << "\\begin_layout Plain Layout\n\n"
+ << rtrim(context.list_preamble)
+ << "\n\\end_layout";
+ end_inset(os);
+ context.list_preamble.clear();
+ }
if (!context.list_extra_stuff.empty()) {
os << context.list_extra_stuff;
context.list_extra_stuff.clear();