5

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!

dollars to pounds

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...

4
  • Please provide a complete, compilable MWE.
    – bodo
    Nov 7, 2012 at 15:35
  • 2
    If only I would get a dollar every time minted encounters an error… :-) Nov 7, 2012 at 16:10
  • Hmm, this smells like a Pygments error. Is your Pygments version up to date? Nov 8, 2012 at 7:50
  • I have Pygments 1.5 installed with easy_install with python 2.7 from Apple (take a look at the error). Are you able to reproduce the error?
    – rano
    Nov 8, 2012 at 8:37

2 Answers 2

5

Saving your postgre code without commenting out the dollars into test.pyg and running

pygmentize -l postgresql -f latex -F tokenmerge -P verboptions=  -o test.out.pyg test.pyg

(the same as the command line used by minted but with \jobname replaced by test) produces the error (I am also using Pygments 1.5).

Thus this is a problem with pygmentize and not minted, and this is probably not the best place to seek help. (Also, I am not familiar with postgresql syntax so suggest you also recheck that the dollars are valid!)

On the other hand, with the dollars commented out, the LaTeX output produced by pygmentize includes the commands \PYZdl{} for the dollars, which \show\PYZdl reveals to be

\char \`\$

and which appear as £s on my system too. Executing \renewcommand{\PYZdl}{\textdollar} before the minted environment addresses that part of the issue. This may be a bug in minted but I am unable to diagnose it further as I cannot easily find out where the \PYZdl macro definition is originally coming from.

2
  • I don't have the \PYZdl command available even after including minted and its configuration. I'm using minted.sty from github.com/gpoore/minted/blob/master/source/minted.sty; I'm on OS X 10.10.1. Pygments version: 2.0.1.
    – mgol
    Jan 3, 2015 at 20:51
  • I've added the \usepackage[T1]{fontenc} pragma just before the \usepackage[utf8]{inputenc} one and it works correctly now.
    – mgol
    Jan 3, 2015 at 21:20
3

I encountered this error today as well. For me the key was to make sure to use correct font encoding:

\usepackage[T1]{fontenc}

The default encoding (using pdfLatex) produced £-symbols.

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .