}
+void Context::check_layout(ostream & os)
+{
+ if (need_layout) {
+ check_end_layout(os);
+
+ os << "\n\\begin_layout " << layout->name() << "\n\n";
+ need_layout=false;
+ need_end_layout = true;
+ if (!extra_stuff.empty()) {
+ os << extra_stuff;
+ extra_stuff.erase();
+ }
+ }
+}
+
+
void Context::check_end_layout(ostream & os)
{
if (need_end_layout) {
os << "\n\\end_layout\n";
need_end_layout = false;
}
- if (need_end_deeper) {
- os << "\n\\end_deeper\n";
- need_end_deeper = false;
- }
}
-void Context::check_layout(ostream & os)
+void Context::check_deeper(ostream & os)
{
- if (need_layout) {
- if (parent_layout->isEnvironment()) {
- if (need_end_deeper) {
+ if (parent_layout->isEnvironment()) {
+ if (need_end_deeper) {
// no need to have \end_deeper \begin_deeper
// FIXME: This does not work because \par already calls check_end_layout
- need_end_deeper = false;
- check_end_layout(os);
- } else {
- check_end_layout(os);
- os << "\n\\begin_deeper\n";
- need_end_deeper = true;
- }
- } else
- check_end_layout(os);
-
- os << "\n\\begin_layout " << layout->name() << "\n\n";
- need_end_layout = true;
- need_layout=false;
- if (!extra_stuff.empty()) {
- os << extra_stuff;
- extra_stuff.erase();
+ need_end_deeper = false;
+ } else {
+ os << "\n\\begin_deeper \n";
+ need_end_deeper = true;
}
+ } else
+ check_end_deeper(os);
+}
+
+
+void Context::check_end_deeper(ostream & os)
+{
+ if (need_end_deeper) {
+ os << "\n\\end_deeper \n";
+ need_end_deeper = false;
}
}
void Context::dump(ostream & os, string const & desc) const
{
- os << desc <<" [";
+ os << "\n" << desc <<" [";
if (need_layout)
os << "need_layout ";
if (need_end_layout)
// Output a \end_layout if needed
void check_end_layout(std::ostream & os);
- // dump content on standard error (for debugging purpose)
+ // Output a \begin_deeper if needed
+ void check_deeper(ostream & os);
+
+ // Output a \end_deeper if needed
+ void check_end_deeper(ostream & os);
+
+ // dump content on stream (for debugging purpose), with
+ // description \c desc.
void dump(std::ostream &, std::string const & desc = "context") const;
// Do we need to output some \begin_layout command before the
Context & parent_context,
LyXLayout_ptr newlayout)
{
-// parent_context.dump(os, "#parent_context before output_command_layout");
parent_context.check_end_layout(os);
Context context(true, parent_context.textclass, newlayout,
parent_context.layout);
+ context.check_deeper(os);
context.check_layout(os);
if (context.layout->optionalargs > 0) {
string s;
}
}
parse_text_snippet(p, os, FLAG_ITEM, outer, context);
- context.check_end_layout(os);
-// context.dump(os, "#context after output_command_layout");
-// parent_context.dump(os, "#parent_context after output_command_layout");
+ context.check_end_layout(os);
+ context.check_end_deeper(os);
}
void parse_environment(Parser & p, ostream & os, bool outer,
Context & parent_context)
{
-// parent_context.dump(os, "#parent_context before parse_environment");
LyXLayout_ptr newlayout;
string const name = p.getArg('{', '}');
const bool is_starred = suffixIs(name, '*');
Context context(true, parent_context.textclass, newlayout,
parent_context.layout);
parent_context.check_end_layout(os);
-// context.dump(os, "#context in parse_environment");
switch (context.layout->latextype) {
case LATEX_LIST_ENVIRONMENT:
context.extra_stuff = "\\labelwidthstring "
default:
break;
}
- //context.check_layout(os);
+ context.check_deeper(os);
parse_text(p, os, FLAG_END, outer, context);
-// context.dump(os, "#context after parse_environment");
context.check_end_layout(os);
+ context.check_end_deeper(os);
} else {
parent_context.check_layout(os);
handle_ert(os, "\\begin{" + name + "}", parent_context);
else if (t.cat() == catNewline) {
if (p.next_token().cat() == catNewline) {
+ // this should have been be done by
+ // the parser already
+ cerr << "what are we doing here?" << endl;
p.get_token();
context.need_layout = true;
- // this should be done by the parser already
- cerr << "what are we doing here?" << endl;
} else {
os << " "; // note the space
}
cerr << "\\end{" + name + "} does not match \\begin{"
+ active_environment() + "}\n";
active_environments.pop_back();
- context.check_end_layout(os);
return;
}
p.error("found 'end' unexpectedly");
p.skip_spaces();
context.check_end_layout(os);
context.need_layout = true;
-// if (p.next_token().cs() != "\\begin")
-// handle_par(os);
- //cerr << "next token: '" << p.next_token().cs() << "'\n";
}
// Must attempt to parse "Section*" before "Section".