string const & i, docstring const & h)
: value_(v), onoff_(o), type_(t), info_(i), hint_(h)
{}
- /// Validate a paramater.
+ /// Validate a parameter.
/// \retval an empty string if \c par is valid.
/// \retval otherwise an explanation WRT to \c par invalidity.
docstring validate(string const & par) const;
bool unclosed = false;
string par2 = par;
// braces are allowed
- if (prefixIs(par, "{") && suffixIs(par, "}") && !suffixIs(par, "\\}"))
+ if (prefixIs(par, "{") && suffixIs(par, "}") && !suffixIs(par, "\\}"))
par2 = par.substr(1, par.size() - 2);
// check for unmatched braces
--braces;
}
unclosed = braces != 0;
-
+
switch (type_) {
case ALL:
/// languages and language/dialect combinations
char const * allowed_languages =
"no language\nABAP\n[R/2 4.3]ABAP\n[R/2 5.0]ABAP\n[R/3 3.1]ABAP\n"
- "[R/3 4.6C]ABAP\n[R/3 6.10]ABAP\nACSL\nAda\n[2005]Ada\n[83]Ada\n"
- "[95]Ada\nALGOL\n[60]ALGOL\n[68]ALGOL\nAssembler\n"
+ "[R/3 4.6C]ABAP\n[R/3 6.10]ABAP\nACM\nACMscript\nACSL\nAda\n[2005]Ada\n[83]Ada\n"
+ "[95]Ada\nALGOL\n[60]ALGOL\n[68]ALGOL\nAnt\nAssembler\n"
"[Motorola68k]Assembler\n[x86masm]Assembler\nAwk\n[gnu]Awk\n[POSIX]Awk\n"
"bash\nBasic\n[Visual]Basic\nC\n[ANSI]C\n[Handel]C\n[Objective]C\n"
"[Sharp]C\nC++\n[ANSI]C++\n[GNU]C++\n[ISO]C++\n[Visual]C++\nCaml\n"
- "[light]Caml\n[Objective]Caml\nClean\nCobol\n[1974]Cobol\n[1985]Cobol\n"
+ "[light]Caml\n[Objective]Caml\nCIL\nClean\nCobol\n[1974]Cobol\n[1985]Cobol\n"
"[ibm]Cobol\nComal 80\ncommand.com\n[WinXP]command.com\nComsol\ncsh\n"
- "Delphi\nEiffel\nElan\nerlang\nEuphoria\nFortran\n[77]Fortran\n[90]Fortran\n"
- "[95]Fortran\nGCL\nGnuplot\nHaskell\nHTML\nIDL\n[CORBA]IDL\ninform\n"
- "Java\n[AspectJ]Java\nJVMIS\nksh\nLingo\nLisp\n[Auto]Lisp\nLogo\n"
- "make\n[gnu]make\nMathematica\n[1.0]Mathematica\n[3.0]Mathematica\n"
+ "Delphi\nEiffel\nElan\nelisp\nerlang\nEuphoria\nFortran\n[77]Fortran\n[90]Fortran\n"
+ "[95]Fortran\n[03]Fortran\n[08]Fortran\nGAP\nGCL\nGnuplot\nGo\nhansl\nHaskell\nHTML\nIDL\n[CORBA]IDL\ninform\n"
+ "Java\n[AspectJ]Java\nJVMIS\nksh\nLingo\nLisp\n[Auto]Lisp\nLLVM\nLogo\n"
+ "Lua\n[5.0]Lua\n[5.1]Lua\n[5.2]Lua\n[5.3]Lua\n"
+ "make\n[gnu]make\nMathematica\n[1.0]Mathematica\n[3.0]Mathematica\n[11.0]Mathematica\n"
"[5.2]Mathematica\nMatlab\nMercury\nMetaPost\nMiranda\nMizar\nML\n"
"Modula-2\nMuPAD\nNASTRAN\nOberon-2\nOCL\n[decorative]OCL\n[OMG]OCL\n"
- "Octave\nOz\nPascal\n[Borland6]Pascal\n[Standard]Pascal\n[XSC]Pascal\n"
+ "Octave\nOORexx\nOz\nPascal\n[Borland6]Pascal\n[Standard]Pascal\n[XSC]Pascal\n"
"Perl\nPHP\nPL/I\nPlasm\nPostScript\nPOV\nProlog\nPromela\nPSTricks\n"
- "Python\nR\nReduce\nRexx\nRSL\nRuby\nS\n[PLUS]S\nSAS\nScilab\nsh\n"
+ "Python\nR\nReduce\nRexx\n[VM/XA]Rexx\nRSL\nRuby\nS\n[PLUS]S\nSAS\nScala\nScilab\nsh\n"
"SHELXL\nSimula\n[67]Simula\n[CII]Simula\n[DEC]Simula\n[IBM]Simula\n"
"SPARQL\nSQL\ntcl\n[tk]tcl\nTeX\n[AlLaTeX]TeX\n[common]TeX\n[LaTeX]TeX\n"
"[plain]TeX\n[primitive]TeX\nVBScript\nVerilog\nVHDL\n[AMS]VHDL\nVRML\n"
"[97]VRML\nXML\nXSLT";
+/// Return language allowed in the GUI without dialect and proper casing
+string const languageonly(string const & lang)
+{
+ string const locase = ascii_lowercase(trim(lang, "{}"));
+ string const all_languages = ascii_lowercase(allowed_languages) + "\n";
+ string language = (lang.at(0) == '[') ? locase + "\n"
+ : string("]") + locase + "\n";
+ size_t i = all_languages.find(language);
+ if (i == string::npos && lang.at(0) != '[') {
+ language[0] = '\n';
+ i = all_languages.find(language);
+ }
+ if (i == string::npos)
+ return lang;
+ if (all_languages.at(i) == '[')
+ i = all_languages.find(']', i);
+ if (i == string::npos)
+ return lang;
+ size_t j = all_languages.find('\n', i + 1);
+ if (j == string::npos)
+ return lang;
+ return string(allowed_languages).substr(i + 1, j - i - 1);
+}
+
+
/// ListingsParam Validator.
/// This class is aimed to be a singleton which is instantiated in
/// \c InsetListingsParams::addParam().
// is to signal that this is a floating listing.
all_params_[1]["float"] =
ListingsParam("false", true, SUBSETOF, "*tbph", empty_hint);
- all_params_[1]["chapter"] =
- ListingsParam("", true, TRUEFALSE, "", _(
- "Number floats by chapter"));
- all_params_[1]["section"] =
- ListingsParam("", true, TRUEFALSE, "", _(
- "Number floats by section"));
all_params_[1]["cache"] =
ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["cachedir"] =
all_params_[1]["outputdir"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["autogobble"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["baselinestretch"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakafter"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakaftergroup"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["breakaftersymbolpre"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakaftersymbolpost"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakanywhere"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["breakanywheresymbolpre"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakanywheresymbolpost"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakautoindent"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["breakbefore"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakbeforegroup"] =
all_params_[1]["breakbeforesymbolpost"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breakbytoken"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["breakbytokenanywhere"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["breakindent"] =
ListingsParam("", false, LENGTH, "", empty_hint);
all_params_[1]["breaklines"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["breaksymbol"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["breaksymbolleft"] =
all_params_[1]["codetagify"] =
ListingsParam("", false, ALL, "", empty_hint);
all_params_[1]["curlyquotes"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["encoding"] =
ListingsParam("", false, ALL, "", _(
"Sets encoding expected by Pygments"));
all_params_[1]["framesep"] =
ListingsParam("", false, LENGTH, "", empty_hint);
all_params_[1]["funcnamehighlighting"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["gobble"] =
ListingsParam("", false, INTEGER, "", empty_hint);
all_params_[1]["highlightcolor"] =
all_params_[1]["lastline"] =
ListingsParam("", false, INTEGER, "", empty_hint);
all_params_[1]["linenos"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["numberfirstline"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["numbers"] =
ListingsParam("", false, ONEOF,
"left\nright\nboth\nnone", empty_hint);
all_params_[1]["mathescape"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["numberblanklines"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["numbersep"] =
ListingsParam("", false, LENGTH, "", empty_hint);
all_params_[1]["obeytabs"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["outencoding"] =
ListingsParam("", false, ALL, "", _(
"File encoding used by Pygments for highlighting"));
all_params_[1]["python3"] =
- ListingsParam("", true, TRUEFALSE, "", _(
+ ListingsParam("", false, TRUEFALSE, "", _(
"Apply Python 3 highlighting"));
- all_params_[1]["resetsmargins"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ all_params_[1]["resetmargins"] =
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["rulecolor"] =
ListingsParam("", false, ALL, "", color_hint_mint);
all_params_[1]["samepage"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["showspaces"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["showtabs"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["space"] =
ListingsParam("", false, ALL, "", _(
"A macro. Default: \\textvisiblespace"));
all_params_[1]["spacecolor"] =
ListingsParam("", false, ALL, "", color_hint_mint);
all_params_[1]["startinline"] =
- ListingsParam("", true, TRUEFALSE, "", _("For PHP only"));
+ ListingsParam("", false, TRUEFALSE, "", _("For PHP only"));
all_params_[1]["style"] =
ListingsParam("", false, ALL, "", _(
"The style used by Pygments"));
all_params_[1]["stepnumber"] =
ListingsParam("", false, INTEGER, "", empty_hint);
all_params_[1]["stepnumberfromfirst"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["stepnumberoffsetvalues"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["stripall"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["stripnl"] =
- ListingsParam("", true, TRUEFALSE, "", empty_hint);
+ ListingsParam("", false, TRUEFALSE, "", empty_hint);
all_params_[1]["tab"] =
ListingsParam("", false, ALL, "", _(
"A macro to redefine visible tabs"));
all_params_[1]["tabsize"] =
ListingsParam("", false, INTEGER, "", empty_hint);
all_params_[1]["texcl"] =
- ListingsParam("", true, TRUEFALSE, "", _(
+ ListingsParam("", false, TRUEFALSE, "", _(
"Enables latex code in comments"));
all_params_[1]["texcomments"] =
- ListingsParam("", true, TRUEFALSE, "", _(
+ ListingsParam("", false, TRUEFALSE, "", _(
"Enables latex code in comments"));
all_params_[1]["xleftmargin"] =
ListingsParam("", false, LENGTH, "", empty_hint);
_("Available listing parameters are %1$s"), from_ascii(param_names));
else
return bformat(
- _("Available listings parameters containing string \"%1$s\" are %2$s"),
+ _("Available listings parameters containing string \"%1$s\" are %2$s"),
from_utf8(suffix), from_utf8(param_names));
}
-
+
// locate name in parameter table
ListingsParams::const_iterator it = all_params_[p].find(name);
if (it != all_params_[p].end()) {
return false;
}
-} // namespace anon.
+} // namespace
// define a global ParValidator
ParValidator * par_validator = 0;
int InsetListingsParams::package_ = 0;
InsetListingsParams::InsetListingsParams()
- : inline_(false), params_(), status_(InsetCollapsable::Open)
+ : inline_(false), params_(), status_(InsetCollapsible::Open)
{
}
InsetListingsParams::InsetListingsParams(string const & par, bool in,
- InsetCollapsable::CollapseStatus s)
+ InsetCollapsible::CollapseStatus s)
: inline_(in), params_(), status_(s)
{
// this will activate parameter validation.
void InsetListingsParams::read(Lexer & lex)
{
lex >> inline_;
- int s = InsetCollapsable::Collapsed;
+ int s = InsetCollapsible::Collapsed;
lex >> s;
- status_ = static_cast<InsetCollapsable::CollapseStatus>(s);
+ status_ = static_cast<InsetCollapsible::CollapseStatus>(s);
string par;
lex >> par;
fromEncodedString(par);
}
-void InsetListingsParams::addParam(string const & key,
- string const & value, bool replace)
+void InsetListingsParams::addParam(string const & key,
+ string const & val, bool replace)
{
if (key.empty())
return;
+ bool const is_minted_language = minted() && key == "language";
+ string const value = (is_minted_language && !val.empty())
+ ? languageonly(val) : val;
// duplicate parameters!
string keyname = key;
if (!replace && hasParam(key))
has_special_char = true;
break;
}
- if (has_special_char)
+ if (has_special_char && !is_minted_language)
params_.push_back(make_pair(keyname, "{" + value + "}"));
else
params_.push_back(make_pair(keyname, value));
} else if (par[i] == '{' && i > 0 && par[i-1] != '\\')
// don't count a brace in first position
++braces;
- else if (par[i] == '}' && i != par.size() - 1
+ else if (par[i] == '}' && i != par.size() - 1
&& (i == 0 || (i > 0 && par[i-1] != '\\')))
--braces;