o $a @sUdZddlmZddlmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZmZdd lmZdd lmZmZmZmZmZmZmZmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)m*Z*ddl+m,Z,m-Z-e,.e/Z0iZ1ee2efe3d<eeddeeddeeddeeddeedddeeddeedddZ4ee2efe3d<e5dde5dde5ddiZ6d Z7d!Z8e 9e j:d"kre7e87Z7Gd#d$d$Z;d%S)&z sphinx.highlighting ~~~~~~~~~~~~~~~~~~~ Highlight code blocks using Pygments. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. )partial) import_module)AnyDict)version) __version__) highlight) ErrorToken) Formatter) HtmlFormatterLatexFormatter)Lexer)CLexer Python3LexerPythonConsoleLexer PythonLexerRstLexer TextLexerget_lexer_by_name guess_lexer)Style)get_style_by_name) ClassNotFound)__) NoneStyle SphinxStyle)logging texescapelexersF)stripnlT)python3r)nonepythonr pyconpycon3restc lexer_classes\z \PYGZbs{}{z \PYGZob{}}z \PYGZcb{}z( \renewcommand\PYGZsq{\textquotesingle} a \makeatletter % fix for Pygments <= 2.7.4 \let\spx@original@fcolorbox\fcolorbox \def\spx@fixpyg@fcolorbox{\fboxsep-\fboxrule\spx@original@fcolorbox} \def\PYG#1#2{\PYG@reset\PYG@toks#1+\relax+% {\let\fcolorbox\spx@fixpyg@fcolorbox\PYG@do{#2}}} \makeatother )c@seZdZeZeZ  ddedededdfdd Zdede fd d Z d e de fd dZ  ddedededede def ddZ  ddedededede d e defddZdefddZdS)PygmentsBridgehtmlsphinxNdest stylename latex_enginereturncCsJ||_||_||}d|i|_|dkr|j|_dS|j|_d|jd<dS)Nstyler/PYG commandprefix)r1r3 get_styleformatter_argshtml_formatter formatterlatex_formatter)selfr1r2r3r5r>5/usr/lib/python3/dist-packages/sphinx/highlighting.py__init__Ms   zPygmentsBridge.__init__cCsN|dus|dkr tS|dkrtSd|vr#|dd\}}tt||St|S)Nr0r!.)rrrsplitgetattrrr)r=r2moduler>r>r?r8ZszPygmentsBridge.get_stylekwargscKs||j|jdi|S)Nr>)updater9r;)r=rFr>r>r? get_formatteres zPygmentsBridge.get_formatterFsourcelangoptsforcelocationcCs|si}|dvr|drd}nd}n|dvr!|drd}nd}|tvr)t|S|tvr7t|d i|}n4z|dkrEt|fi|}nt|fi|}Wntyjtjtd ||d td d i|}Ynw|sr| d |S)N)pyr"z>>>r#r")py3r defaultr$r guessz#Pygments lexer name %r is not known)rMr! raiseonerrorr>) startswithrr'rrrloggerwarningr add_filter)r=rIrJrKrLrMlexerr>r>r? get_lexeris8     zPygmentsBridge.get_lexerc Kst|ts |}||||||}|jdi|}zt|||} Wn)tyK|dkr.n tjt d|dd|d||d|||}t|||} Ynw|j dkrS| St | |j S) NrPz:Could not lex literal_block as "%s". Highlighting skipped.mischighlighting_failure)typesubtyperMr!r/r>) isinstancestrdecoderXrHrr rTrUrr1rhlescaper3) r=rIrJrKrLrMrFrWr;hlsourcer>r>r?highlight_blocks(    zPygmentsBridge.highlight_blockcCs(|}|jdkr|dS|tS)Nr/z .highlight)rHr1get_style_defs_LATEX_ADD_STYLES)r=r;r>r>r?get_stylesheets   zPygmentsBridge.get_stylesheet)r/r0N)NFN)__name__ __module__ __qualname__r r:r r<r^r@rr8rr rHrboolr rXrbrer>r>r>r?r.GsB     ' r.N)<__doc__ functoolsr importlibrtypingrr packagingrpygmentsrpygmentsversionrpygments.filtersr pygments.formatterr pygments.formattersr r pygments.lexerr pygments.lexersrrrrrrrrpygments.stylerpygments.stylesr pygments.utilr sphinx.localersphinx.pygments_stylesrr sphinx.utilrr getLoggerrfrTrr^__annotations__r'ordescape_hl_charsrd_LATEX_ADD_STYLES_FIXPYGparsereleaser.r>r>r>r?sJ       (