char const * const known_ref_commands[] = { "ref", "pageref", "vref",
"vpageref", "prettyref", "eqref", 0 };
+char const * const known_coded_ref_commands[] = { "ref", "pageref", "vref",
+ "vpageref", "formatted", "eqref", 0 };
+
/*!
* natbib commands.
* The starred forms are also known except for "citefullauthor",
char const * const known_tex_extensions[] = {"tex", 0};
/// spaces known by InsetSpace
-char const * const known_spaces[] = { " ", "space", ",", "thinspace", "quad",
-"qquad", "enspace", "enskip", "negthinspace", "hfill", "dotfill", "hrulefill",
-"leftarrowfill", "rightarrowfill", "upbracefill", "downbracefill", 0};
+char const * const known_spaces[] = { " ", "space", ",",
+"thinspace", "quad", "qquad", "enspace", "enskip",
+"negthinspace", "negmedspace", "negthickspace", "textvisiblespace",
+"hfill", "dotfill", "hrulefill", "leftarrowfill", "rightarrowfill",
+"upbracefill", "downbracefill", 0};
/// the same as known_spaces with .lyx names
char const * const known_coded_spaces[] = { "space{}", "space{}",
"thinspace{}", "thinspace{}", "quad{}", "qquad{}", "enspace{}", "enskip{}",
-"negthinspace{}", "hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}",
-"rightarrowfill{}", "upbracefill{}", "downbracefill{}", 0};
+"negthinspace{}", "negmedspace{}", "negthickspace{}", "textvisiblespace{}",
+"hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}", "rightarrowfill{}",
+"upbracefill{}", "downbracefill{}", 0};
/// These are translated by LyX to commands like "\\LyX{}", so we have to put
/// them in ERT. "LaTeXe" must come before "LaTeX"!
p.next_token().character() != '[')
break;
p.get_token(); // eat '['
- begin_inset(os, "OptArg\n");
+ begin_inset(os, "Argument\n");
os << "status collapsed\n\n";
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
end_inset(os);
++optargs;
}
unsigned int reqargs = 0;
- while (LYX_FORMAT >= 392 && reqargs < context.layout->reqargs) {
+ while (reqargs < context.layout->reqargs) {
eat_whitespace(p, os, context, false);
if (p.next_token().cat() != catBegin)
break;
p.get_token(); // eat '{'
- begin_inset(os, "OptArg\n");
+ begin_inset(os, "Argument\n");
os << "status collapsed\n\n";
parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
end_inset(os);
os << "has_inner_box " << !inner_type.empty() << "\n";
os << "inner_pos \"" << inner_pos << "\"\n";
os << "use_parbox " << (inner_type == "parbox") << '\n';
+ os << "use_makebox 0\n";
os << "width \"" << width_value << width_unit << "\"\n";
os << "special \"none\"\n";
os << "height \"" << height_value << height_unit << "\"\n";
Context context(true, parent_context.textclass);
context.font = parent_context.font;
+ // FIXME, the inset layout should be plain, not standard, see bug #7846
+
// If we have no inner box the contens will be read with the outer box
if (!inner_type.empty())
parse_text(p, os, inner_flags, outer, context);
p.skip_spaces();
}
+ else if (unstarred_name == "sidewaysfigure"
+ || unstarred_name == "sidewaystable") {
+ eat_whitespace(p, os, parent_context, false);
+ parent_context.check_layout(os);
+ if (unstarred_name == "sidewaysfigure")
+ begin_inset(os, "Float figure\n");
+ else
+ begin_inset(os, "Float table\n");
+ os << "wide " << convert<string>(is_starred)
+ << "\nsideways true"
+ << "\nstatus open\n\n";
+ parse_text_in_inset(p, os, FLAG_END, outer, parent_context);
+ end_inset(os);
+ // We don't need really a new paragraph, but
+ // we must make sure that the next item gets a \begin_layout.
+ parent_context.new_paragraph(os);
+ p.skip_spaces();
+ }
+
+ else if (name == "wrapfigure" || name == "wraptable") {
+ // syntax is \begin{wrapfigure}[lines]{placement}[overhang]{width}
+ eat_whitespace(p, os, parent_context, false);
+ parent_context.check_layout(os);
+ // default values
+ string lines = "0";
+ string overhang = "0col%";
+ // parse
+ if (p.hasOpt())
+ lines = p.getArg('[', ']');
+ string const placement = p.getArg('{', '}');
+ if (p.hasOpt())
+ overhang = p.getArg('[', ']');
+ string const width = p.getArg('{', '}');
+ // write
+ if (name == "wrapfigure")
+ begin_inset(os, "Wrap figure\n");
+ else
+ begin_inset(os, "Wrap table\n");
+ os << "lines " << lines
+ << "\nplacement " << placement
+ << "\noverhang " << lyx::translate_len(overhang)
+ << "\nwidth " << lyx::translate_len(width)
+ << "\nstatus open\n\n";
+ parse_text_in_inset(p, os, FLAG_END, outer, parent_context);
+ end_inset(os);
+ // We don't need really a new paragraph, but
+ // we must make sure that the next item gets a \begin_layout.
+ parent_context.new_paragraph(os);
+ p.skip_spaces();
+ }
+
else if (name == "minipage") {
eat_whitespace(p, os, parent_context, false);
parse_box(p, os, 0, FLAG_END, outer, parent_context, "", "", name);
context.check_layout(os);
need_layout = false;
}
- begin_inset(os, "OptArg\n");
+ begin_inset(os, "Argument\n");
os << "status collapsed\n\n";
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
end_inset(os);
++optargs;
}
unsigned int reqargs = 0;
- while (LYX_FORMAT >= 392 && reqargs < context.layout->reqargs) {
+ while (reqargs < context.layout->reqargs) {
eat_whitespace(p, os, context, false);
if (p.next_token().cat() != catBegin)
break;
context.check_layout(os);
need_layout = false;
}
- begin_inset(os, "OptArg\n");
+ begin_inset(os, "Argument\n");
os << "status collapsed\n\n";
parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
end_inset(os);
os << subst(t.asInput(), "\\", "\n\\backslash\n");
else {
ostringstream oss;
- begin_inset(oss, "Newline newline");
- end_inset(oss);
+ Context tmp(false, context.textclass,
+ &context.textclass[from_ascii("Scrap")]);
+ tmp.need_end_layout = true;
+ tmp.check_layout(oss);
os << subst(t.asInput(), "\n", oss.str());
}
// The scrap chunk is ended by an @ at the beginning of a line.
if (p.next_token().cat() != catEscape &&
p.next_token().character() == '[') {
p.get_token(); // eat '['
- begin_inset(os, "OptArg\n");
+ begin_inset(os, "Argument\n");
os << "status collapsed\n";
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
end_inset(os);
}
else if (t.cs() == "underbar" || t.cs() == "uline") {
+ // \underbar is not 100% correct (LyX outputs \uline
+ // of ulem.sty). The difference is that \ulem allows
+ // line breaks, and \underbar does not.
// Do NOT handle \underline.
// \underbar cuts through y, g, q, p etc.,
// \underline does not.
os << "\n\\bar default\n";
}
- else if (t.cs() == "emph" || t.cs() == "noun") {
+ else if (t.cs() == "sout") {
+ context.check_layout(os);
+ os << "\n\\strikeout on\n";
+ parse_text_snippet(p, os, FLAG_ITEM, outer, context);
+ context.check_layout(os);
+ os << "\n\\strikeout default\n";
+ }
+
+ else if (t.cs() == "uuline" || t.cs() == "uwave" ||
+ t.cs() == "emph" || t.cs() == "noun") {
context.check_layout(os);
os << "\n\\" << t.cs() << " on\n";
parse_text_snippet(p, os, FLAG_ITEM, outer, context);
os << "\n\\" << t.cs() << " default\n";
}
+ // FIXME, the inset layout should be plain, not standard, see bug #7846
+ else if (t.cs() == "phantom" || t.cs() == "hphantom" ||
+ t.cs() == "vphantom") {
+ context.check_layout(os);
+ if (t.cs() == "phantom")
+ begin_inset(os, "Phantom Phantom\n");
+ if (t.cs() == "hphantom")
+ begin_inset(os, "Phantom HPhantom\n");
+ if (t.cs() == "vphantom")
+ begin_inset(os, "Phantom VPhantom\n");
+ os << "status open\n";
+ parse_text_in_inset(p, os, FLAG_ITEM, outer, context);
+ end_inset(os);
+ }
+
+ else if (t.cs() == "href") {
+ context.check_layout(os);
+ string target = p.getArg('{', '}');
+ string name = p.getArg('{', '}');
+ string type;
+ size_t i = target.find(':');
+ if (i != string::npos) {
+ type = target.substr(0, i + 1);
+ if (type == "mailto:" || type == "file:")
+ target = target.substr(i + 1);
+ // handle the case that name is equal to target, except of "http://"
+ else if (target.substr(i + 3) == name && type == "http:")
+ target = name;
+ }
+ begin_command_inset(os, "href", "href");
+ if (name != target)
+ os << "name \"" << name << "\"\n";
+ os << "target \"" << target << "\"\n";
+ if (type == "mailto:" || type == "file:")
+ os << "type \"" << type << "\"\n";
+ end_inset(os);
+ skip_spaces_braces(p);
+ }
+
else if (t.cs() == "lyxline") {
+ // swallow size argument (it is not used anyway)
+ p.getArg('{', '}');
+ if (!context.atParagraphStart()) {
+ // so our line is in the middle of a paragraph
+ // we need to add a new line, lest this line
+ // follow the other content on that line and
+ // run off the side of the page
+ // FIXME: This may create an empty paragraph,
+ // but without that it would not be
+ // possible to set noindent below.
+ // Fortunately LaTeX does not care
+ // about the empty paragraph.
+ context.new_paragraph(os);
+ }
+ if (h_paragraph_separation == "indent") {
+ // we need to unindent, lest the line be too long
+ context.add_par_extra_stuff("\\noindent\n");
+ }
context.check_layout(os);
- os << "\\lyxline";
+ begin_command_inset(os, "line", "rule");
+ os << "offset \"0.5ex\"\n"
+ "width \"100line%\"\n"
+ "height \"1pt\"\n";
+ end_inset(os);
+ }
+
+ else if (t.cs() == "rule") {
+ string const offset = (p.hasOpt() ? p.getArg('[', ']') : string());
+ string const width = p.getArg('{', '}');
+ string const thickness = p.getArg('{', '}');
+ context.check_layout(os);
+ begin_command_inset(os, "line", "rule");
+ if (!offset.empty())
+ os << "offset \"" << translate_len(offset) << "\"\n";
+ os << "width \"" << translate_len(width) << "\"\n"
+ "height \"" << translate_len(thickness) << "\"\n";
+ end_inset(os);
}
else if (is_known(t.cs(), known_phrases) ||
string const opt = p.getOpt();
if (opt.empty()) {
context.check_layout(os);
- begin_command_inset(os, "ref", t.cs());
+ char const * const * where = is_known(t.cs(),
+ known_ref_commands);
+ begin_command_inset(os, "ref",
+ known_coded_ref_commands[where - known_ref_commands]);
os << "reference \""
<< convert_command_inset_arg(p.verbatim_item())
<< "\"\n";
else if (t.cs() == "index") {
context.check_layout(os);
- begin_inset(os, "Index\n");
+ begin_inset(os, "Index idx\n");
os << "status collapsed\n";
parse_text_in_inset(p, os, FLAG_ITEM, false, context, "Index");
end_inset(os);
else if (t.cs() == "printindex") {
context.check_layout(os);
begin_command_inset(os, "index_print", "printindex");
+ os << "type \"idx\"\n";
end_inset(os);
skip_spaces_braces(p);
}
else if (t.cs() == "printnomenclature") {
+ string width = "";
+ string width_type = "";
context.check_layout(os);
begin_command_inset(os, "nomencl_print", "printnomenclature");
+ // case of a custom width
+ if (p.hasOpt()) {
+ width = p.getArg('[', ']');
+ width = translate_len(width);
+ width_type = "custom";
+ }
+ // case of no custom width
+ // the case of no custom width but the width set
+ // via \settowidth{\nomlabelwidth}{***} cannot be supported
+ // because the user could have set anything, not only the width
+ // of the longest label (which would be width_type = "auto")
+ string label = convert_command_inset_arg(p.getArg('{', '}'));
+ if (label.empty() && width_type.empty())
+ width_type = "none";
+ os << "set_width \"" << width_type << "\"\n";
+ if (width_type == "custom")
+ os << "width \"" << width << '\"';
end_inset(os);
skip_spaces_braces(p);
}
- else if (LYX_FORMAT >= 408 &&
- (t.cs() == "textsuperscript" || t.cs() == "textsubscript")) {
+ else if ((t.cs() == "textsuperscript" || t.cs() == "textsubscript")) {
context.check_layout(os);
begin_inset(os, "script ");
os << t.cs().substr(4) << '\n';