
    Ki%                         d dl Z d dlZd dlZd dlZddlmZ ddlmZmZ ddl	m
Z
 d	dZd Zedk    r e             dS dS )
    N   )latexwalker)LatexNodes2Text_strict_latex_spaces_predef)version_strc           	      
   | t           j        dd          } t          j        dd          }|                    d          }|                    dddd d	d
           |                    dddd           |                    d          }|                    ddddd t          j                   |                    ddddt          j                   |                    ddddd           |                    ddddd           |                    dddddt          j                   |                    d dddt          j                   |                    d!          }|                    d"ddd#d t          j                   |                    d$ddd#t          j                   |                    d%dd&g d'd(d)*           |                    d+d,dd-d.d/0           |                    d1ddd2d           |                    d3ddd2d4            G fd5d6t                     d7d8gt          d9 t          j	                    D                       z   d:g          }|                    d;|d<d=d>?           |                    d@dddAd           |                    dBdddAdC           |                    dDt          dEdFdGH           |                    dI          }|                    dJdKdLdt          j        t          j        dMN           |                    dOdPdLdt          j        dQR           |                    dSdTdU                    t                     dVW           |                    dXdYdZ[           |                    |           }t          j                     t          j                                        |j                   t          j        t,                    }|j        |j        |                    d\           d]}|j        r8|j        r)|                    d^           t          j        d           |j        }n"t=          j        |j        _          D ]}||z  }|j         d.k    r3|j         )tC          |j                   rt          |j                   }	nd}	nd }	tE          j#        ||j$        |j%        `          }
|
&                                \  }}}tO          |j(        |j)        |j*        |j+        |j,        |	a          }t[          |.                    |                     d S )bN   
latex2textF)progadd_helpzInput optionsz--codez-cstore
LATEX_CODEzConvert the given LATEX_CODE to unicode text instead of reading from FILE or standard input.  You cannot specify FILEs if you use this option, and any standard input is ignored.)actiondefaultmetavarhelpfilesFILE*zInput files to read LaTeX code from. If no FILE(s) is/are specified, LaTeX code is read from standard input unless --code is specified)r   nargsr   zLatexWalker optionsz--parser-keep-inline-mathstore_constTparser_keep_inline_math)r   constdestr   r   z--no-parser-keep-inline-math)r   r   r   r   z--tolerant-parsingtolerant_parsing)r   r   r   r   z--no-tolerant-parsingzJTolerate syntax errors when parsing, and attempt to continue (default yes)z--strict-bracesstrict_bracesz--no-strict-braceszLatexNodes2Text optionsz--text-keep-inline-mathtext_keep_inline_mathz--no-text-keep-inline-mathz--math-mode	math_mode)textzwith-delimitersverbatimremover   zHow to handle chunks of math mode LaTeX code. 'text' = convert to text like the rest; 'with-delimiters' = same as 'text' but retain the original math mode delimiters; 'verbatim' = keep verbatim LaTeX code; 'remove' = remove from input entirely)r   r   choicesr   r   z--fill-text	fill_text?z^Attempt to wrap text to the given width, or 80 columns if option is specified with no argument)r   r   r   r   r   z--keep-commentskeep_commentsz--no-keep-commentsz/Keep LaTeX comments in text output (default no)c                   .     e Zd Z fdZ fdZ xZS )!main.<locals>.ListWithHiddenItemsc                 \    t          |                               |           || _        d S N)super__init__hiddenitems)selfthelistr-   ListWithHiddenItems	__class__s      v/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pylatexenc/latex2text/__main__.pyr,   z*main.<locals>.ListWithHiddenItems.__init__p   s0    %t,,55g>>>*D    c                 \    t          |                               |          p|| j        v S r*   )r+   __contains__r-   )r.   valuer0   r1   s     r2   r5   z.main.<locals>.ListWithHiddenItems.__contains__s   s4    ,d33@@GG -D,,-r3   )__name__
__module____qualname__r,   r5   __classcell__)r1   r0   s   @r2   r0   r(   o   s\        	+ 	+ 	+ 	+ 	+ 	+	- 	- 	- 	- 	- 	- 	- 	- 	- 	-r3   r0   offonc              3   &   K   | ]}|d k    |V  dS )r   N ).0ks     r2   	<genexpr>zmain.<locals>.<genexpr>y   s'      [[AQZNN1NNNN[[r3   r   z--strict-latex-spacesstrict_latex_spacesmacroszLHow to handle whitespace. See documentation for the class LatexNodes2Text().)r"   r   r   r   z--keep-braced-groupskeep_braced_groupsz--no-keep-braced-groupsz6Keep LaTeX {braced groups} in text output (default no)z--keep-braced-groups-minlenr   keep_braced_groups_minlenzTOnly apply --keep-braced-groups to groups that contain at least this many characters)typer   r   r   zGeneral optionsz-qz--quietlogging_levelzSuppress warning messages)r   r   r   r   r   z-vz	--verbosezVerbose output)r   r   r   r   z	--versionversionzpylatexenc {}z!Show version information and exit)r   rH   r   z--helpr   z#Show this help information and exit)r   r   zOptions --parser-keep-inline-math and --text-keep-inline-math are deprecated and no longer have any effect.  Please use --math-mode=... instead. zTCannot specify both FILEs and --code option. Use --help option for more information.)r   )r   r   )r   r&   rB   rD   rE   r#   )/sysargvargparseArgumentParseradd_argument_groupadd_argumentSUPPRESSlistr   keysintloggingERRORINFODEBUGformatr   
parse_argsbasicConfig	getLoggersetLevelrG   r7   r   r   warningcoder   errorexit	fileinputinputr#   lenr   LatexWalkerr   r   get_latex_nodesr   r   r&   rB   rD   rE   printnodelist_to_text)rK   parser	codegroupgroupstrict_latex_spaces_choicesargsloggerlatexliner#   lwnodelistposlen_ln2tr0   s                  @r2   mainru   %   s   |x|$,GGGF))/::I8T'4Q]!H  I I I 7F#!_  ` ` ` %%&;<<E	2=PT5t$-  / / / 
5mSX5$-  / / / 
+M.  > > >	.}E.h  j j j )-t,e%.  0 0 0 ,]%,%.  0 0 0
 %%&?@@E	0d3T$-  / / / 
3MQV3$-  / / / 
}W;PPP%?  @ @ @ 
};wc!4  5 5 5
 
(d+U  < < <	+M+M  O O O- - - - - - -d - - - #6"5	d[[&A&F&H&H[[[[[[		# # 
.8S18,  - - -
 
-m40%  A A A	0e0T  V V V 
437.  / / /
 %%&788E	tY_]$]GL7  9 9 9 
t[}$],  . . . 
{9.55kBB?  A A A 
xA  C C C T""D  !3444x((F #/43M3Y 2 	3 	3 	3 Ey : 	LL C D D DHQKKK	O$*555 	 	DTMEE~>%#dn*=*=%DN++IIII			 262G/3/A
C 
C 
CB ..00XsDT^)-);/3/G.2.E595S%.0 0 0D 
$


)
)*****r3   c                      	 t                       d S # t          $ r   dd l} dd l}|                                 |                                  Y d S xY w)Nr   )ru   
SystemExitpdb	traceback	print_excpost_mortem)rx   ry   s     r2   run_mainr|      sr    
   


s	    <A__main__r*   )rJ   ra   rL   rT   rI   r   r
   r   r   rH   r   ru   r|   r7   r>   r3   r2   <module>r~      s   4 


             E E E E E E E E ! ! ! ! ! !b+ b+ b+ b+L   zDFFFFF r3   