Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
Please provide a complete, compilable MWE. –  canaaerus Nov 7 '12 at 15:35
2  
If only I would get a dollar every time minted encounters an error… :-) –  Harold Cavendish Nov 7 '12 at 16:10
    
Hmm, this smells like a Pygments error. Is your Pygments version up to date? –  Konrad Rudolph Nov 8 '12 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 '12 at 8:37

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
1  
See fontenc vs inputenc. –  Martin Schröder Feb 20 at 10:00
1  
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Martin Schröder Feb 20 at 10:00
    
Thank you @MartinSchröder . That taught me something I'd completely missed. Edited answer accordingly. –  Jonas Kalderstam Feb 23 at 22:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.