Hi Tim,
thanks for your help, I'm getting closer to the 'big picture', maybe...
Il giorno lun, 11/10/2010 alle 09.55 -0700, Tim Hatch ha scritto:
> Hi Federico,
>
> > Unfortunately I can't go on if I can't test what I'm writing...
>
> My first suggestion for making a LilyPond lexer available to Pygments is
> to try it as a plugin. These are fairly simple to do -- juts make a
> file with your lexer in it, then use setup.py metadata to let Pygments
> find it, and run setup.py develop (in your virtualenv should be fine).
>
The setup.py yuo are talking about is the one I create inside my plugin,
right?
I have to write two files, but I can't understand where I'm supposed to
put them...
Let's say that my plugin, called lily, has the following tree:
lily
├── ext
│ └── pygmentplugin.py
└── setup.py
Where should I copy lily/ ?
I tried to put it in the top directory of pygments/ source directory.
Then I run 'python setup.py develop' (in my virtualenv), but my lexer is
not recognized if I type 'pygmentize -L'.
What am I missing?
> One simple example is at
> http://groups.google.com/group/sphinx-dev/msg/ccb822e8abc51893 and a
> fuller example is how mako provides a lexer,
>
too concise for me, I'm afraid
> http://hg.makotemplates.org/mako/file/7bd9f5bec61d/mako/ext/pygmentplugin.py
> http://hg.makotemplates.org/mako/file/7bd9f5bec61d/setup.py
> (specifically entry_points=)
>
I wrote my files using these ones as a basis.
I attach them just in case it helps to find some error.
Thanks,
Federico
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.
from setuptools import setup, find_packages
import os
import re
import sys
setup(name='LilyPond',
version="0.1",
description="Music typesetting language",
author='Federico Bruni',
author_email='[email protected]',
license='MIT',
entry_points="""
[pygments.lexers]
lily = lily.ext.pygmentplugin:LilyLexer
""",
)
# Do I really need these imports?
from pygments.lexer import Lexer, LexerContext, RegexLexer, ExtendedRegexLexer, \
bygroups, include, using, this, do_insertions
from pygments.token import Punctuation, Text, Comment, Keyword, Name, String, \
Generic, Operator, Number, Whitespace, Literal
class LilyLexer(RegexLexer):
name = 'LilyLexer'
aliases = ['lily']
filenames = ['*.ly']
mimetypes = ['text/x-lilypond']
tokens = {
'general': [
(r'%.*?\n', Comment),
]
}