}
+string const Parser::plainCommand(char left, char right, string const & name)
+{
+ if (!good())
+ return string();
+ // ceck if first token is really the start character
+ Token tok = get_token();
+ if (tok.character() != left) {
+ cerr << "first character does not match start character of command \\" << name << endl;
+ return string();
+ }
+ ostringstream os;
+ for (Token t = get_token(); good(); t = get_token()) {
+ if (t.character() == right) {
+ return os.str();
+ } else
+ os << t.asInput();
+ }
+ cerr << "unexpected end of input" << endl;
+ return os.str();
+}
+
+
void Parser::tokenize_one()
{
catInit();
* This function is designed to parse verbatim environments.
*/
std::string const plainEnvironment(std::string const & name);
+ /*
+ * Basically the same as plainEnvironment(std::string const & name) but
+ * instead of \begin and \end commands the parsing is started/stopped
+ * at given characters.
+ * This function is designed to parse verbatim commands.
+ */
+ std::string const plainCommand(char left, char right, std::string const & name);
/*!
* Returns the character of the current token and increments
* the token position.
}
-void parse_listings(Parser & p, ostream & os, Context & parent_context)
+void parse_listings(Parser & p, ostream & os, Context & parent_context, bool in_line)
{
parent_context.check_layout(os);
begin_inset(os, "listings\n");
}
os << "lstparams " << '"' << arg << '"' << '\n';
}
- os << "inline false\n"
- << "status collapsed\n";
+ if (in_line)
+ os << "inline true\n";
+ else
+ os << "inline false\n";
+ os << "status collapsed\n";
Context context(true, parent_context.textclass);
context.layout = &parent_context.textclass.plainLayout();
- string const s = p.plainEnvironment("lstlisting");
+ string s;
+ if (in_line) {
+ s = p.plainCommand('!', '!', "lstinline");
+ context.new_paragraph(os);
+ context.check_layout(os);
+ } else
+ s = p.plainEnvironment("lstlisting");
for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
if (*it == '\\')
os << "\n\\backslash\n";
eat_whitespace(p, os, parent_context, false);
// FIXME handle the automatic color package loading
// uwestoehr asks: In what case color is loaded?
- parse_listings(p, os, parent_context);
+ parse_listings(p, os, parent_context, false);
p.skip_spaces();
}
end_inset(os);
}
+ else if (t.cs() == "lstinline") {
+ p.skip_spaces();
+ parse_listings(p, os, context, true);
+ }
+
else if (t.cs() == "ensuremath") {
p.skip_spaces();
context.check_layout(os);