def some_function():
interesting = False
print 'This line is highlighted.'
print 'This one is not...'
print '...but this one is.'
-
-
Save bgeron/6b0fd37124ab91843fee to your computer and use it in GitHub Desktop.
Patching the LaTeX output of Sphinx with line highligting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Generated by Sphinx. | |
\def\sphinxdocclass{report} | |
\documentclass[letterpaper,10pt,english]{sphinxmanual} | |
\usepackage[utf8]{inputenc} | |
\DeclareUnicodeCharacter{00A0}{\nobreakspace} | |
\usepackage{cmap} | |
\usepackage[T1]{fontenc} | |
\usepackage{babel} | |
\usepackage{times} | |
\usepackage[Bjarne]{fncychap} | |
\usepackage{longtable} | |
\usepackage{sphinx} | |
\usepackage{multirow} | |
\addto\captionsenglish{\renewcommand{\figurename}{Fig. }} | |
\addto\captionsenglish{\renewcommand{\tablename}{Table }} | |
\floatname{literal-block}{Listing } | |
\title{p Documentation} | |
\date{December 20, 2015} | |
\release{v} | |
\author{a} | |
\newcommand{\sphinxlogo}{} | |
\renewcommand{\releasename}{Release} | |
\makeindex | |
\makeatletter | |
% (omitted some lines) | |
\makeatother | |
\renewcommand\PYGZsq{\textquotesingle} | |
\begin{document} | |
\maketitle | |
\tableofcontents | |
\phantomsection\label{index::doc} | |
\begin{Verbatim}[commandchars=\\\{\}] | |
\PYG{k}{def} \PYG{n+nf}{some\PYGZus{}function}\PYG{p}{(}\PYG{p}{)}\PYG{p}{:} | |
\PYG{n}{interesting} \PYG{o}{=} \PYG{n+nb+bp}{False} | |
\PYG{k}{print} \PYG{l+s}{\PYGZsq{}}\PYG{l+s}{This line is highlighted.}\PYG{l+s}{\PYGZsq{}} | |
\PYG{k}{print} \PYG{l+s}{\PYGZsq{}}\PYG{l+s}{This one is not...}\PYG{l+s}{\PYGZsq{}} | |
\PYG{k}{print} \PYG{l+s}{\PYGZsq{}}\PYG{l+s}{...but this one is.}\PYG{l+s}{\PYGZsq{}} | |
\end{Verbatim} | |
\renewcommand{\indexname}{Index} | |
\printindex | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Generated by Sphinx. | |
\def\sphinxdocclass{report} | |
\documentclass[letterpaper,10pt,english]{sphinxmanual} | |
\usepackage[utf8]{inputenc} | |
\DeclareUnicodeCharacter{00A0}{\nobreakspace} | |
\usepackage{cmap} | |
\usepackage[T1]{fontenc} | |
\usepackage{babel} | |
\usepackage{times} | |
\usepackage[Bjarne]{fncychap} | |
\usepackage{longtable} | |
\usepackage{sphinx} | |
\usepackage{multirow} | |
\addto\captionsenglish{\renewcommand{\figurename}{Fig. }} | |
\addto\captionsenglish{\renewcommand{\tablename}{Table }} | |
\floatname{literal-block}{Listing } | |
\title{p Documentation} | |
\date{December 20, 2015} | |
\release{v} | |
\author{a} | |
\newcommand{\sphinxlogo}{} | |
\renewcommand{\releasename}{Release} | |
\makeindex | |
\makeatletter | |
% (omitted some lines) | |
\makeatother | |
\renewcommand\PYGZsq{\textquotesingle} | |
\begin{document} | |
\maketitle | |
\tableofcontents | |
\phantomsection\label{index::doc} | |
\begin{Verbatim}[commandchars=\\\{\}] | |
\PYG{k}{def} \PYG{n+nf}{some\PYGZus{}function}\PYG{p}{(}\PYG{p}{)}\PYG{p}{:} | |
\PYG{n}{interesting} \PYG{o}{=} \PYG{n+nb+bp}{False} | |
\colorbox{yellow}{\!\! \PYG{k}{print} \PYG{l+s}{\PYGZsq{}}\PYG{l+s}{This line is highlighted.}\PYG{l+s}{\PYGZsq{}}} | |
\PYG{k}{print} \PYG{l+s}{\PYGZsq{}}\PYG{l+s}{This one is not...}\PYG{l+s}{\PYGZsq{}} | |
\colorbox{yellow}{\!\! \PYG{k}{print} \PYG{l+s}{\PYGZsq{}}\PYG{l+s}{...but this one is.}\PYG{l+s}{\PYGZsq{}}} | |
\end{Verbatim} | |
\renewcommand{\indexname}{Index} | |
\printindex | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment