I'm using minted to try to list & color some pieces of plpgsql (PostgreSQL's plsql), namely some functions and triggers. The problem appears when I write the dollars as
$$
or
$BODY$
which are needed to specify the body of the function. Here is an example:
\begin{minted}{postgresql}
CREATE EXTENSION IF NOT EXISTS dblink;
CREATE OR REPLACE FUNCTION update_vendite()
RETURNS int
AS
$BODY$
DECLARE
quantitaV int;
tot double precision;
BEGIN
SELECT INTO quantitaV qta
FROM vendite_ft WHERE id=2'
RETURN quantitaV;
END;
$BODY$
LANGUAGE 'plpgsql';
\end{minted}
When I try to compile (I'm using TexShop 3.11 for OS X Lion) I get this error from pygments:
*** Error while highlighting:
TypeError: 'NoneType' object is not subscriptable
(file "/Library/Python/2.7/site-packages/Pygments-1.5-py2.7.egg/pygments/formatters/latex.py", line 133, in _get_ttype_name)
(./es_progetto.out.pyg)
it appears as if that syntax is not supported (ignoring the error and continuing compiling gives a listed code printed and stopped at the first $BODY$
included, removing the $BODY$
s from the code gives no error at all).
Am I missing something using minted? How can I circumvent this?
UPDATE: I've found this related question here which makes me wonder if you can reproduce the error or it is just me who gets it.
UPDATE2 Here is a mwe that still gets me the error:
\documentclass[11pt]{article}
\usepackage{minted}
\begin{document}
\begin{minted}{postgresql}
CREATE EXTENSION IF NOT EXISTS dblink;
CREATE OR REPLACE FUNCTION update_vendite()
RETURNS int
AS
$BODY$
DECLARE
quantitaV int;
tot double precision;
BEGIN
SELECT INTO quantitaV qta
FROM dblink('hostaddr=127.0.0.1 port=5433 dbname=autoricambi
user=foodmart password=foodmart',
'SELECT qta, pz_unit FROM vendite_ft WHERE id=2')
AS t(qta int, pz_unit double precision);
RETURN quantitaV;
END;
$BODY$
LANGUAGE 'plpgsql';
\end{minted}
\end{document}
UPDATE 3
This is an interesting issue: if I comment the $BODY$
line with plpgsql comment syle ('--'
) minted does not give an error but in the output the dollars are substituted with the pound symbol!
can anybody confirm this issue too? can this be related to localization?
UPDATE 4
Based on the hypotesis that the pygment lexer is the problem, I tried to use only $BODY
and it works, the problem lies on the fact that the last dollar is unrecognized. It appears that pygments uses an external lexer for the strings starting with a dollar...
minted
encounters an error… :-)