}
context.check_deeper(os);
context.check_layout(os);
- if (context.layout->optionalargs > 0) {
+ unsigned int optargs = 0;
+ while (optargs < context.layout->optargs) {
eat_whitespace(p, os, context, false);
- if (p.next_token().character() == '[') {
- p.get_token(); // eat '['
- begin_inset(os, "OptArg\n");
- os << "status collapsed\n\n";
- parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
- end_inset(os);
- eat_whitespace(p, os, context, false);
- }
+ if (p.next_token().character() != '[')
+ break;
+ p.get_token(); // eat '['
+ begin_inset(os, "OptArg\n");
+ os << "status collapsed\n\n";
+ parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
+ end_inset(os);
+ eat_whitespace(p, os, context, false);
+ optargs++;
}
+#if 0
+ // This is the code needed to parse required arguments, but
+ // required arguments come into being only much later than the
+ // file format tex2lyx is presently outputting.
+ unsigned int reqargs = 0;
+ while (reqargs < context.layout->reqargs) {
+ eat_whitespace(p, os, context, false);
+ if (p.next_token().character() != '{')
+ break;
+ p.get_token(); // eat '{'
+ begin_inset(os, "OptArg\n");
+ os << "status collapsed\n\n";
+ parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
+ end_inset(os);
+ eat_whitespace(p, os, context, false);
+ reqargs++;
+ }
+#endif
parse_text(p, os, FLAG_ITEM, outer, context);
context.check_end_layout(os);
if (parent_context.deeper_paragraph) {
if (FileName::isAbsolute(name))
return;
- name = to_utf8(makeRelPath(from_utf8(makeAbsPath(name, getMasterFilePath()).absFilename()),
+ name = to_utf8(makeRelPath(from_utf8(makeAbsPath(name, getMasterFilePath()).absFileName()),
from_utf8(getParentFilePath())));
}
if (t.character() == ']' && (flags & FLAG_BRACK_LAST))
return;
+ if (t.character() == '}' && (flags & FLAG_BRACE_LAST))
+ return;
//
// cat codes
if (!after.empty()) {
after.erase(0, 1);
after.erase(after.length() - 1, 1);
+ // LyX cannot handle newlines in the parameter
+ after = subst(after, "\n", " ");
}
if (!before.empty()) {
before.erase(0, 1);
before.erase(before.length() - 1, 1);
+ // LyX cannot handle newlines in the parameter
+ before = subst(before, "\n", " ");
}
begin_inset(os, "LatexCommand ");
os << t.cs() << "\n";
}
if (makeAbsPath(filename, path).exists()) {
string const abstexname =
- makeAbsPath(filename, path).absFilename();
+ makeAbsPath(filename, path).absFileName();
string const abslyxname =
changeExtension(abstexname, ".lyx");
fix_relative_filename(filename);