Skip to content

Commit 17e6a0a

Browse files
committed
Add Cython language definition for listings package
1 parent 44e4eff commit 17e6a0a

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

doc/.src/book/make.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ if start != -1 and end != -1:
123123
text = text.replace(r"\usepackage{ucs}", r"%\usepackage{ucs} % DISABLED: causes encoding issues with utf8x")
124124
text = text.replace(r"\usepackage[utf8x]{inputenc}", r"\usepackage[utf8]{inputenc} % Changed from utf8x to utf8")
125125
126+
# Fix 3: Add Cython language definition for listings package.
127+
# DocOnce generates language=cython for .pyx files, but listings doesn't have cython built-in.
128+
cython_def = r'''
129+
% Cython language definition for listings (Cython is a superset of Python)
130+
\lstdefinelanguage{cython}[]{python}{
131+
morekeywords={cdef,cpdef,ctypedef,cimport,DEF,IF,ELIF,ELSE,nogil,gil,with,extern,namespace,fused,readonly,public,api,inline,bint,Py_ssize_t},
132+
}
133+
'''
134+
# Insert after \begin{document}
135+
text = text.replace(r"\begin{document}", cython_def + r"\begin{document}")
136+
126137
path.write_text(text)
127138
PY
128139
# With t4/svmono linewidth has some too large value before \mymainmatter
-1.99 MB
Binary file not shown.
-2 MB
Binary file not shown.

0 commit comments

Comments
 (0)