2 # Minted External Template
4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
7 # author Enrico Forestieri
9 # Full author contact details are available in file CREDITS.
11 # External templates expect to deal with commands of the form
12 # \command[options]{parameter}
13 # while the \inputminted command has the form
14 # \inputminted[options]{language}{filename}
16 # In order to use the external templates machinery, the options of the
17 # minted package are extended to be able to construct a proper \inputminted
18 # command. This template defines an additional 'language' option for minted,
19 # which is then extracted from the options and passed as the second non-optional
20 # parameter of \inputminted. This template works for minted version 2.1 or
21 # higher. As it relies on the internals of minted, an update might break it.
25 \@namedef{minted@opt@cmd@lang}{latex}
26 \define@key{minted@opt@cmd}{language}{\@namedef{minted@opt@cmd@lang}{#1}
27 \minted@configlang{#1}}
28 \DeclareRobustCommand\inputsource{\@ifnextchar[\@inputsrc{\@inputsrc[]}}
29 \def\@inputsrc[#1]#2{\inputminted[#1]{\minted@opt@cmd@lang}{#2}}
33 GuiName "Minted Source Code"
35 Format source code using the 'minted' package.
36 This template works with minted version 2.1 or higher.
37 The source language is specified by the 'language' option,
38 which must be inserted into the 'Option' field in the
39 'LaTeX and LyX options' tab.
42 * linenos,fontsize=\footnotesize,language=fortran
43 * bgcolor=yellow,baselinestretch=1.2,language=c
44 * frame=lines,framesep=2\fboxsep,language=python
46 If 'language=xxx' is not given, 'language=latex' is assumed by default.
47 Make sure to use the '-shell-escape' option for the latex backend.
48 Read the documentation of the minted package
49 for further options and details.
53 AutomaticProduction true
54 Preview InstantPreview
58 TransformOption Extra ExtraOption
59 Option Arg "[$$Extra]"
60 Product "\\inputsource$$Arg{$$AbsPath$$Basename$$Extension}"
62 UpdateResult "$$AbsPath$$Basename$$Extension"
63 ReferencedFile text "$$AbsPath$$Basename$$Extension"
67 TransformOption Extra ExtraOption
68 Option Arg "[$$Extra]"
69 Product "\\inputsource$$Arg{$$AbsPath$$Basename$$Extension}"
71 UpdateResult "$$AbsPath$$Basename$$Extension"
72 ReferencedFile text "$$AbsPath$$Basename$$Extension"
75 Product "$$Contents(\"$$AbsPath$$Basename$$Extension\")"
77 UpdateResult "$$AbsPath$$Basename$$Extension"