+
     ]i  c                   s   R t ^ RIt^ RIHt ^ RIHt ^ RIHtHt ^ RI	t	^ RI
HtHt ^ RIt^ RIHtHt ^ RIHt  ! R R	]P&                  ]P(                  4      tR
 t/ . 3R ltR]R]/]n         ! R R]4      tRR ltR tR tR tR# )a  
A role and directive to display mathtext in Sphinx
==================================================

The ``mathmpl`` Sphinx extension creates a mathtext image in Matplotlib and
shows it in html output. Thus, it is a true and faithful representation of what
you will see if you pass a given LaTeX string to Matplotlib (see
:ref:`mathtext`).

.. warning::
    In most cases, you will likely want to use one of `Sphinx's builtin Math
    extensions
    <https://www.sphinx-doc.org/en/master/usage/extensions/math.html>`__
    instead of this one. The builtin Sphinx math directive uses MathJax to
    render mathematical expressions, and addresses accessibility concerns that
    ``mathmpl`` doesn't address.

Mathtext may be included in two ways:

1. Inline, using the role::

     This text uses inline math: :mathmpl:`\alpha > \beta`.

   which produces:

     This text uses inline math: :mathmpl:`\alpha > \beta`.

2. Standalone, using the directive::

     Here is some standalone math:

     .. mathmpl::

         \alpha > \beta

   which produces:

     Here is some standalone math:

     .. mathmpl::

         \alpha > \beta

Options
-------

The ``mathmpl`` role and directive both support the following options:

fontset : str, default: 'cm'
    The font set to use when displaying math. See :rc:`mathtext.fontset`.

fontsize : float
    The font size, in points. Defaults to the value from the extension
    configuration option defined below.

Configuration options
---------------------

The mathtext extension has the following configuration options:

mathmpl_fontsize : float, default: 10.0
    Default font size, in points.

mathmpl_srcset : list of str, default: []
    Additional image sizes to generate when embedding in HTML, to support
    `responsive resolution images
    <https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images>`__.
    The list should contain additional x-descriptors (``'1.5x'``, ``'2x'``,
    etc.) to generate (1x is the default and always included.)

N)Path)nodes)	Directive
directives)ConfigErrorExtensionError)_apimathtext)validate_float_or_Nonec                   s    ] tR t^WtRtR# )
latex_math N)__name__
__module____qualname____firstlineno____static_attributes__r
       C/usr/lib64/python3.14/site-packages/matplotlib/sphinxext/mathmpl.pyr	   r	   W   s    r   r	   c                 s`    \         P                  ! V \        P                  P                  4      # N)r   Zchoicer   ZMathTextParserZ_font_type_mapping)Zargs   &r   fontset_choicer   [   s!    S("9"9"L"LMMr   c                 s    VP                  R 4      pW^,           R p\        V4      p	WR&   VP                  RR4      V	R&   VP                  R\        P                  P
                  P                  4      V	R&   V	.. 3# )Z`latexfontsetcmfontsize)Zfindr	   getsetupappconfigmathmpl_fontsize)
ZroleZrawtextZtextZlinenoZinlineroptionscontentir   nodes
   &&&&&&&   r   	math_roler"   _   sw    SAaCOEgDMkk)T2DO{{:#(99#3#3#D#DFD62:r   r   r   c                   sF   a  ] tR t^mt o RtRt^ t^ tRtR]	R]
/tR tRtV tR# )	MathDirectivezJ
The ``.. mathmpl::`` directive, as documented in the module's docstring.
TFr   r   c                s0   R P                  V P                  4      p\        V P                  4      pWR&   V P                  P                  RR4      VR&   V P                  P                  R\        P                  P                  P                  4      VR&   V.# ) r   r   r   r   )
joinr   r	   Z
block_textr   r   r   r   r   r   )selfr   r!   s   &  r   runZMathDirective.runx   sy    %$//*W,,**9d;Y<<++J,1II,<,<,M,MOZvr   r
   N)r   r   r   r   __doc__Zhas_contentZrequired_argumentsZoptional_argumentsZfinal_argument_whitespacer   r   Zoption_specr'   r   Z__classdictcell__)Z__classdict__s   @r   r#   r#   m   s?      K %n57K r   r#   c           	      s   \         P                  ! R VRV/4      ;_uu_ 4         \        P                  ! RV  R2WRR7      pRRR4       V#   \         d    \
        P                  ! RT  24       ^ p L2i ; i  + '       g   i     X# ; i)zmathtext.fontsetz	font.sizeZ$Zpng)dpiformatz!Could not render math expression N)mplZ
rc_contextr   Zmath_to_imageZ	Exceptionr   Zwarn_external)r   filenamer   r   r)   depths   &&&&& r   	latex2pngr.      s    	+Wk8L	M	M	**E7!h?E 
N L  	!B5'JKE		 
N	M Ls(   A8A&A52A84A55A88B		c                 s~   \        V P                  \        P                  4      pV R ,          pV R,          pV R,          pRP	                  \
        P                  ! V V V 2P                  4       RR7      P                  4       RR 4      p\        \        P                  P                  P                  RR4      pVP                  R	R	R
7       Wv R2,          p\        W8WER7      p	. p
\        P                  P                   P"                   F~  pV RVP%                  RR4       R2p\        W7V,          WE^d\'        VRR 4      ,          R7       V
P)                  \        P                  P                  P*                   RV RV 24       K  	  V
'       dI   R\        P                  P                  P*                   RV R2RP-                  V
4      ,           R,           p
V'       d   RpMRpV'       d   V	^ 8w  d   RV	^,           ,          pMRpR\        P                  P                  P*                   RV RV
 V V R2	# )r   r   r   zmath-{}F)ZusedforsecurityNZ_imagesmathmplT)ZparentsZexist_okz.png)r   Z-Z.Z_)r   r)   z	/mathmpl/Z zsrcset="z.png, z, z" r$   zclass="center" z)style="position: relative; bottom: -%dpx"z
<img src="z.png" z/>ir   )
isinstanceparentr   TextElementr*   hashlibZsha256ZencodeZ	hexdigestr    r   r   ZbuilderZoutdirZmkdirr.   r   mathmpl_srcsetZreplacefloatappendZimgpathr%   )r!   sourceinliner   r   r   ZnameZdestdirZdestr-   Zsrcsetsizer,   ZclsZstyles   &&             r   
latex2htmlr:      s   U%6%67FME9oGJHggYxj)002!	
 )+cd	D 599$$++Y	BGMM$M.vT]"De7>EF		  //V1T\\#s34D9%8+WE$s),,	.yy  (()8*AdVD	F	 0 UYY..667yfM))F#$&*+ %1*;uqyI**2239TF CxuUG2' (r   c                 s    \        V P                  P                  4       F2  w  r#VR,          R8X  d    \        VRR 4       K$  \        RV: R24      h	  R#   \         d    \        RT: R24      hi ; i)   ZxNz,Invalid value for mathmpl_srcset parameter: ze. Must be a list of strings with the multiplicative factor followed by an "x".  e.g. ["2.0x", "1.5x"]r   )Z	enumerater   r4   r5   Z
ValueErrorr   )r   r   r    r9   s   &&  r   _config_initedr<      s    SZZ6678s?Id3Bi  >th GD DE E 8  I!B4( KH HI IIs   AA4c                 s   V \         n        V P                  R RR4       V P                  R. R4        V P                  R\        4       R pR pR	 pR
 pV P                  \        W3W43R7       V P                  R\        4       V P                  R\        4       \        P                  R8  d-   V P                  R\        4       V P                  R\        4       RRRR/pV#   \
         d    T P                  RR 4        Li ; i)r   g      $@Tr4   zconfig-initedzenv-updatedc                 s    \        V R 4      # r   )r<   )r   Zenv   &&r   Z<lambda>Zsetup.<locals>.<lambda>   s    N34Mr   c                 s    V P                   P                  R ,          pV P                  P                  \	        W4      4       R# )r7   N)ZdocumentZ
attributesbodyr6   r:   )r&   r!   r7      && r   visit_latex_math_htmlZ$setup.<locals>.visit_latex_math_html   s-    ))(3		D12r   c                     R # r   r
   r&   r!   r=   r   depart_latex_math_htmlZ%setup.<locals>.depart_latex_math_html       r   c                 s    \        VP                  \        P                  4      pV'       d,   V P                  P                  R VR,          ,          4       R# V P                  P                  RVR,          R.4       R# )z$%s$r   z\begin{equation}z\end{equation}N)r0   r1   r   r2   r>   r6   Zextend)r&   r!   r8   r?   r   visit_latex_math_latexZ%setup.<locals>.visit_latex_math_latex   sZ    DKK):):;IIVd7m34II1"7m/1 2r   c                 rA   r   r
   rB   r=   r   depart_latex_math_latexZ&setup.<locals>.depart_latex_math_latex   rD   r   )Zhtmlr   r/   ZmathZparallel_read_safeZparallel_write_safe)r;   i   )r   r   Zadd_config_valueZconnectr<   r   Zadd_noder	   Zadd_roler"   Zadd_directiver#   sphinxZversion_info)r   r@   rC   rE   rF   Zmetadatas   &     r   r   r      s    EI+T48)2t4OO^4
32 LL,E.H  J LLI&i/V#VY'&-0$d,A4HHOE  OM#MNOs   C$ $DD)r   i
   id   )r(   r3   Zpathlibr    Zdocutilsr   Zdocutils.parsers.rstr   r   rG   Zsphinx.errorsr   r   Z
matplotlibr+   r   r   Zmatplotlib.rcsetupr   ZGeneralZElementr	   r   r"   r   r#   r.   r:   r<   r   r
   r   r   <module>rH      s   FP    6  5  % 5	 	N
 "	 !79	 I ,&(RE$(r   