I wrote a new lexer for pygments and I try to use it. Thus I look at this page
http://pygments.org/docs/lexerdevelopment/
where the install procedure is described. They said to do make mapfiles
but I don't know where.
I look into this two directories where there is the other.py module they talk about.
/usr/share/pyshared/pygments/lexers/
and
/usr/share/pyshared/pygments/lexers/
But there is not any makefiles in there. Thus how can I do ?
The blog post Custom syntax in pygments explains another way to add a custom lexer to pygments:
Pygments enables custom plugins via something called entrypoints in setuptools.
Directory structure:
|- FantomLexer
|- fantomlexer
| |- __init__.py
| |- lexer.py
|- setup.py
The __init__.py
file can be empty but it needs to be there so its enough to simply touch it. The lexer.py
will contain the regex lexer for pygments.
The contents of the setup.py
goes as following:
from setuptools import setup, find_packages
setup (
name='fantomlexer',
packages=find_packages(),
entry_points =
"""
[pygments.lexers]
fantomlexer = fantomlexer.lexer:FantomLexer
""",
)
You can then install your lexer via sudo python setup.py develop
.
I found a solution which works. I guess you lexer is in the file mylex.py
. I did the following under ubuntu 13.10. You need to have root permissions to do that.
/usr/share/pyshared/pygments/lexers/
python _mapping.py
Do a symbolic link of your lexer into /usr/lib/python2.7/dist-packages/pygments/lexers/
. For example :
cd /usr/lib/python2.7/dist-packages/pygments/lexers/
ln -s /usr/share/pyshared/pygments/lexers/algobox.py .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With