summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/moodle/test/test_minted.tex
blob: cc9458eb0ce922bd4c6608b21452434fdf33fa66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
% !TeX encoding = UTF-8
% !TeX spellcheck = en_US
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage[nostamp]{moodle}
\ifPDFTeX % FOR LATEX and PDFLATEX
	\usepackage[utf8]{inputenc} % necessary
	\usepackage[T1]{fontenc} % necessary
\else % assuming XELATEX or LUALATEX
	\usepackage{fontspec}
\fi
\usepackage{minted}
\usemintedstyle{tango}
%\RecustomVerbatimEnvironment{Verbatim}{LVerbatim}{}
\begin{document}

\section*{Introduction}

This document is intended to check the support of the \textsf{minted} package.

The only command supported is 
\texttt{inputminted[<options>]\{<lang>\}\{<filename>\}}.

\begin{quiz}{Minted}

\setminted{numbersep=3ex,tabsize=4,numberblanklines=false,autogobble=true}

\begin{VerbatimOut}{_minted-test_minted/test.tex}
  % !TeX encoding = UTF-8
  % !TeX spellcheck = en_US
  % !TEX TS-program = xelatex
  
  \documentclass{article}
  \usepackage[nostamp]{moodle}
  \newif\iffvextra
  \fvextratrue
  \ifxetex % FOR XELATEX
   \usepackage{fontspec}
  \else %% FOR PDFLATEX
  	\usepackage[utf8]{inputenc} % necessary
  	\usepackage[T1]{fontenc} % necessary
  \fi
\end{VerbatimOut}
\setminted[latex]{firstline=3,firstnumber=2,lastline=9,numbers=both,style=xcode}

\begin{VerbatimOut}{_minted-test_minted/test.py}
n = int(input('Type a number, and its factorial will be printed: '))

if n < 0:
    raise ValueError('non negative integer expected')

fact = 1

for i in range(2, n + 1):
    fact *= i

print(fact)
\end{VerbatimOut}
\setminted[python]{firstline=3,firstnumber=2,lastline=9,numbers=both,style=xcode}

\begin{VerbatimOut}{_minted-test_minted/test.c}
long some_function();
/* int */ other_function();

/* int */ calling_function()
{
    long test1;
    register /* int */ test2;

    test1 = some_function();
    if (test1 > 0)
          test2 = 0;
    else
          test2 = other_function();
    return test2;
}
\end{VerbatimOut}
\setminted[c]{style=tango,numberblanklines=true,highlightlines={2,4,7}}

\begin{VerbatimOut}{_minted-test_minted/test.pl}
#!/usr/bin/XXXX
use strict;
use warnings;
use IO::Handle;

my ( $remaining, $tot );

$remaining = $tot = shift(@ARGV);

STDOUT->autoflush(1);

while ( $remaining ) {
  printf ( "Remaining %s/%s \r", $remaining--, $tot );
  sleep 1;
}

print "\n";
\end{VerbatimOut}
\setminted[perl]{firstline=1,firstnumber=1,lastline=19,numbers=left}

\begin{numerical}[tolerance=0]{LaTeX Classes}
In the following \LaTeX\ code excerpt, on which line is the class loaded?
\inputminted{latex}{_minted-test_minted/test.tex}
\item[feedback={yes! 
\inputminted[highlightlines={3}]{latex}{_minted-test_minted/test.tex}},fraction=100]
 4
\item[feedback={No. On line 3, there is only a comment.},fraction=0] 3
\item[feedback={No. On line 5, the package \texttt{moodle} is 
loaded.},fraction=0] 5
\end{numerical}

% To avoid collision of line and item numbers in PDF, force `left-right' mode:
\RecustomVerbatimEnvironment{Verbatim}{LVerbatim}{frame=lines,
    label={[Beginning of code]End of code},framesep=3mm,numbersep=9pt}%
\begin{multi}{Languages}
Select the code written in the Python language.
\item[feedback={Indeed, this is Python code.}]* 
\inputminted[highlightlines={2,4-5},numbers=both]{python}{_minted-test_minted/test.py}
\item[feedback={No. This is Perl code.}]
\inputminted[highlightlines={2,4-5},numbers=right,style=colorful]{perl}{_minted-test_minted/test.pl}
\item[feedback={No. This is C code.}]
\inputminted[numbers=left]{c}{_minted-test_minted/test.c}
\end{multi}


\end{quiz}

\end{document}