+ if (isInline) {
+ char const * delimiter = lstinline_delimiters;
+ for (; delimiter != '\0'; ++delimiter)
+ if (!contains(code, *delimiter))
+ break;
+ // This code piece contains all possible special character? !!!
+ // Replace ! with a warning message and use ! as delimiter.
+ if (*delimiter == '\0') {
+ code = subst(code, from_ascii("!"), from_ascii(" WARNING: no lstline delimiter can be used "));
+ delimiter = lstinline_delimiters;
+ }
+ if (param_string.empty())
+ os << "\\lstinline" << *delimiter;
+ else
+ os << "\\lstinline[" << from_ascii(param_string) << "]" << *delimiter;
+ os << code
+ << *delimiter;
+ } else {
+ OutputParams rp = runparams;
+ // FIXME: the line below would fix bug 4182,
+ // but real_current_font moved to cursor.
+ //rp.local_font = &text_.real_current_font;
+ rp.moving_arg = true;
+ docstring const caption = getCaption(buf, rp);
+ runparams.encoding = rp.encoding;
+ if (param_string.empty() && caption.empty())
+ os << "\n\\begingroup\n\\inputencoding{latin1}\n\\begin{lstlisting}\n";
+ else {
+ os << "\n\\begingroup\n\\inputencoding{latin1}\n\\begin{lstlisting}[";
+ if (!caption.empty()) {
+ os << "caption={" << caption << '}';
+ if (!param_string.empty())
+ os << ',';
+ }
+ os << from_utf8(param_string) << "]\n";
+ }
+ lines += 4;
+ os << code << "\n\\end{lstlisting}\n\\endgroup\n";