]> git.lyx.org Git - features.git/blob - lib/xtemplates/minted.xtemplate
Typo in comment
[features.git] / lib / xtemplates / minted.xtemplate
1 #
2 # Minted External Template
3 #
4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
6 #
7 # author Enrico Forestieri
8 #
9 # Full author contact details are available in file CREDITS.
10 #
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}
15 #
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.
22
23 PreambleDef minted
24     \usepackage{minted}
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}}
30 PreambleDefEnd
31
32 Template MintedSource
33     GuiName "Minted Source Code"
34     HelpText
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.
40
41         Example options:
42         * linenos,fontsize=\footnotesize,language=fortran
43         * bgcolor=yellow,baselinestretch=1.2,language=c
44         * frame=lines,framesep=2\fboxsep,language=python
45
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.
50     HelpTextEnd
51     InputFormat text
52     FileFilter "*"
53     AutomaticProduction true
54     Preview InstantPreview
55     Transform Extra
56     Format LaTeX
57         Preamble minted
58         TransformOption Extra ExtraOption
59         Option Arg "[$$Extra]"
60         Product "\\inputsource$$Arg{$$AbsPath$$Basename$$Extension}"
61         UpdateFormat text
62         UpdateResult "$$AbsPath$$Basename$$Extension"
63         ReferencedFile text "$$AbsPath$$Basename$$Extension"
64     FormatEnd
65     Format PDFLaTeX
66         Preamble minted
67         TransformOption Extra ExtraOption
68         Option Arg "[$$Extra]"
69         Product "\\inputsource$$Arg{$$AbsPath$$Basename$$Extension}"
70         UpdateFormat text
71         UpdateResult "$$AbsPath$$Basename$$Extension"
72         ReferencedFile text "$$AbsPath$$Basename$$Extension"
73     FormatEnd
74     Format Ascii
75         Product "$$Contents(\"$$AbsPath$$Basename$$Extension\")"
76         UpdateFormat text
77         UpdateResult "$$AbsPath$$Basename$$Extension"
78     FormatEnd
79 TemplateEnd