Hi, Le 22/10/23 à 15h51, Denis Bitouzé a écrit :
> (Question already asked but still not answered on SO: > https://stackoverflow.com/q/77329701/1682470) > > I created Pygments customized lexer and style: > > - `acetexlexer.py` (lexer file), > - `acedracula.py` (style file), > > that work pretty well since the following command returns the expected > result: > > ┌──── > │ pygmentize -O style=acedracula -x -l acetexlexer.py:AceTexLexer test.tex > └──── > > But I can't get them to work with Sphinx, despite extensive research on > the Internet. Okay, I succeeded, thanks to: ┌──── │ https://stackoverflow.com/a/62084359/1682470 └──── For the record, here is how I could make it work. 1. In fact, no need to create a `_pygments/` directory containing: - `acetexlexer.py` (lexer file), - `acedracula.py` (style file). 2. (As I did from the beginning, ) - the `acetexlexer.py` file is in the directory (in my case) `~/.local/lib/python3.10/site-packages/pygments/lexers`, - the `acedracula.py` file is in the directory (in my case) `~/.local/lib/python3.10/site-packages/pygments/styles` with: ┌──── │ 'acedracula': 'acedracula::AceDraculaStyle', └──── in the `STYLE_MAP` dictionary in the `__init__.py` file in this directory. 3. In the `source/_ext` directory, I created a file named (for the moment) `test.py` containing: ┌──── │ from pygments.lexers.acetexlexer import AceTexLexer │ │ def setup(app): │ app.add_lexer('xlatex', AceTexLexer) │ return { │ 'parallel_read_safe': True, │ 'parallel_write_safe': True, │ } └──── (the 4 last line in order to be able to distribute the build over N processes in parallel: `-j` option of `sphinx-build`). 4. In `conf.py`, I removed the `def setup(app):` function and everything related to lexers but added to the `extensions` list, the 'test' extension (see `test.py` above). So far, so good. Now, I've no idea what could be a proper name instead of `test.py` for my `test` “extension”. I guess reusing the same name `acetexlexer.py` as used for my own lexer would be a bad idea. Any suggestion is welcome. Thanks! -- Denis -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/87cyx5vece.fsf%40example.com.