+
    i                        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                       ] tR t^WtRtR# )
latex_math N)__name__
__module____qualname____firstlineno____static_attributes__r       |/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/matplotlib/sphinxext/mathmpl.pyr   r   W   s    r   r   c                 `    \         P                  ! V \        P                  P                  4      # N)r   choicer	   MathTextParser_font_type_mapping)args   &r   fontset_choicer   [   s!    S("9"9"L"LMMr   c                     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# )`latexfontsetcmfontsize)findr   getsetupappconfigmathmpl_fontsize)
rolerawtexttextlinenoinlineroptionscontentir   nodes
   &&&&&&&   r   	math_roler2   _   sw    SAaCOEgDMkk)T2DO{{:#(99#3#3#D#DFD62:r   r   r!   c                   F   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                0   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   
block_textr.   r$   r%   r&   r'   r(   )selfr   r1   s   &  r   runMathDirective.runx   sy    %$//*W,,**9d;Y<<++J,1II,<,<,M,MOZvr   r   N)r   r   r   r   __doc__has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   r
   option_specr:   r   __classdictcell__)__classdict__s   @r   r4   r4   m   s?      K %n57K r   r4   c           	         \         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.size$png)dpiformatz!Could not render math expression N)mpl
rc_contextr	   math_to_image	Exceptionr   warn_external)r   filenamer   r!   rG   depths   &&&&& r   	latex2pngrP      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                 ~   \        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)usedforsecurityN_imagesmathmplT)parentsexist_okz.png)r!   -._)r!   rG   z	/mathmpl/ zsrcset="z.png, z, z" r6   zclass="center" z)style="position: relative; bottom: -%dpx"z
<img src="z.png" z/>ir"   )
isinstanceparentr   TextElementrH   hashlibsha256encode	hexdigestr   r%   r&   builderoutdirmkdirrP   r'   mathmpl_srcsetreplacefloatappendimgpathr7   )r1   sourceinliner   r   r!   namedestdirdestrO   srcsetsizerN   clsstyles   &&             r   
latex2htmlrs      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                     \        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)   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"   )	enumerater'   re   rg   
ValueErrorr   )r&   r'   r0   rp   s   &&  r   _config_initedry      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                    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      $@Tre   zconfig-initedzenv-updatedc                     \        V R 4      # r   )ry   )r&   envs   &&r   <lambda>setup.<locals>.<lambda>   s    N34Mr   c                     V P                   P                  R ,          pV P                  P                  \	        W4      4       R# )rj   N)document
attributesbodyrh   rs   )r9   r1   rj   s   && r   visit_latex_math_html$setup.<locals>.visit_latex_math_html   s-    ))(3		D12r   c                     R # r   r   r9   r1   s   &&r   depart_latex_math_html%setup.<locals>.depart_latex_math_html       r   c                     \        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)r[   r\   r   r]   r   rh   extend)r9   r1   rk   s   && r   visit_latex_math_latex%setup.<locals>.visit_latex_math_latex   sZ    DKK):):;IIVd7m34II1"7m/1 2r   c                     R # r   r   r   s   &&r   depart_latex_math_latex&setup.<locals>.depart_latex_math_latex   r   r   )htmlr   rT   mathparallel_read_safeparallel_write_safe)ru      )r%   r&   add_config_valueconnectry   r   add_noder   add_roler2   add_directiver4   sphinxversion_info)r&   r   r   r   r   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    
   d   )r<   r^   pathlibr   docutilsr   docutils.parsers.rstr   r   r   sphinx.errorsr   r   
matplotlibrI   r   r	   matplotlib.rcsetupr
   GeneralElementr   r   r2   r.   r4   rP   rs   ry   r%   r   r   r   <module>r      s   FP    6  5  % 5	 	N
 "	 !79	 I ,&(RE$(r   