Hi,

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

I tried for instance the following setup, partially based on:

  ┌────
  │ https://github.com/AdaCore/aunit/blob/v21.0.0/doc/share/ada_pygments.pyhttps://github.com/AdaCore/aunit/blob/v21.0.0/doc/share/conf.py
  └────

that I found from:

  ┌────
  │ https://github.com/sphinx-doc/sphinx/issues/9544
  └────

1. At the root of the `source` of the project, I created a `_pygments`
   subdirectory containing the lexer and style files (`acetexlexer.py` and
   `qacedracula.py`).
2. The relevant lines of `acetexlexer.py` are:
  ┌────
  │ from pygments.lexer import inherit, bygroups
  │ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
  │     Number, Punctuation, Generic, Other, Whitespace
  │ from pygments.lexers.markup import TexLexer
  │ 
  │ __all__ = ['AceTexLexer']
  │ 
  │ class AceTexLexer(TexLexer):
  │     aliases = ['xtex', 'xlatex']
  └────
3. The relevant lines of my `conf.py` file are:
  ┌────
  │ import os
  │ import sys
  │ sys.path.insert(0, os.path.abspath('.'))
  │ sys.path.append(os.path.abspath("./_ext"))
  │ sys.path.append(os.path.abspath("./_pygments"))
  │ 
  │ def setup(app):
  │     from acetexlexer import AceTexLexer
  │     app.add_lexer('xlatex', acetexlexer.AceTexLexer)
  └────

But, when I run:

  ┌────
  │ sphinx-build -v -j auto source build/html source/test.md
  └────

I get:

  ┌────
  │ [...]/source/test.md:16: WARNING: Pygments lexer name 'xlatex' is not known.
  └────

What am I doing wrong?

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/87bkcqojdy.fsf%40example.com.

Reply via email to