Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: allow to specify options to pass to pygmentize #49

Closed
brabalan opened this issue Sep 5, 2014 · 5 comments
Closed

Feature request: allow to specify options to pass to pygmentize #49

brabalan opened this issue Sep 5, 2014 · 5 comments

Comments

@brabalan
Copy link

brabalan commented Sep 5, 2014

I wrote a filter for pygments that I would like to use for some minted listing. I have not found a way to tell minted to call pygmentize with a -F kwrenamefilter option (it's the name of my filter).

@gpoore
Copy link
Owner

gpoore commented Sep 8, 2014

There isn't a documented way to do this (yet), but you can use the internal macros to add a new option.

If your filter takes an argument, something like this in your preamble, after loading minted, should work. Then you can use kwrename as an option.

\makeatletter
\minted@define@opt{kwrename}{-F kwrenamefilter}{#1}
\makeatother

If your filter is just an on/off boolean, then something like this should work.

\makeatletter
\minted@define@switch{kwrename}{-F kwrenamefilter}
\makeatother

@brabalan
Copy link
Author

I tried with this latex file (compiled with xelatex -shell-escape test.tex) and it does not work.

\documentclass[11pt]{article}
\usepackage{minted}
\usemintedstyle{emacs}
\makeatletter
\minted@define@switch{kwrename}{-F kwrenamefilter}
\makeatother

\begin{document}

This is a test of the filter.

\begin{minted}[kwrename]{coq}
Lemma foo : forall x, x -> x.
\end{minted}

\end{document}

I'm using the minted from texlive 2013. Is is recent enough?

@brabalan
Copy link
Author

If you want to test, the filter is here: https://github.com/brabalan/kwrenamefilter

The output should be like this: "Lemma foo : ∀ x, x → x."

@gpoore
Copy link
Owner

gpoore commented Sep 11, 2014

Well, this turned out to be quite tricky. What I suggested would have worked in most cases, but it failed in this case because the substitution you were doing involved Unicode. You will need the latest version of minted.sty from GitHub (development version), because the version in TeX Live doesn't have encoding support. (If your operating system's native encoding is UTF8, things might work with your current version of minted.sty, but you would have to experiment.) You will also need to configure your document to work with the Unicode symbols you want. This preamble should work. You will need to adjust it for other symbols, or find a package that will define everything you want.

\usepackage{newunicodechar}
\newunicodechar{∀}{$\forall$}
\usepackage{minted}
\usemintedstyle{emacs}
\setminted{encoding=utf8}
\makeatletter
\minted@define@switch{kwrename}{-F kwrenamefilter}
\makeatother

By the way, pdflatex worked with this preamble:

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{minted}
\usemintedstyle{emacs}
\setminted{encoding=utf8}
\makeatletter
\minted@define@switch{kwrename}{-F kwrenamefilter}
\makeatother

@brabalan
Copy link
Author

Thank you, this worked great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants