
    kKj%                        d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZ d dlmZ d dlmZ d dlmZmZ  ej,                  e      Zd	ed
ededeeeef   fdZ e eddd       eddd       eddd       eddd       eddd       eddd       eddd       eddd       edd d!       eddd      g eddd       eddd       eddd       eddd       eddd       eddd       edd d!       eddd      g      Zeeee
ed"Zde j:                  fd#Zdefd$Zed%k(  r e         ej@                   e              yy)&    N)Tuple)Console)Panel)DIMMED_MONOKAIDEFAULT_TERMINAL_THEMEMONOKAINIGHT_OWLISHTerminalTheme)Text)install)RestructuredText__version__rgbreturnc                     | ||fS )zRepresent color in RGB format. )r   r   r   s      b/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/rich_rst/__main__.pyrgbr      s    q!9    (   *   6            U   P      {                  y               )draculamonokaiz	night-owlzdimmed-monokaidefaultc            	      f   t        j                  d      } | j                  dddt                | j                  ddd	d
d       | j                  ddddd       | j                  dddt        dd       | j                  ddt
        dd
d       | j                  ddt        d d!d"       | j                  d#d$d%t        d&d'       | j                  d(dd)d*+       | j                  d,d-t        d.d
d/       | j                  d0d1d2dd3       | j                  d4d5dd6d7+       | j                  d8d9dd:d;+       | j                  d<d=t        d>d?d@       | j                  dAdBddCdD+       | j                  dEdFt        dGdGdHgdIJ       | j                  dKdLt        dMt        t              dNJ       | j                  dOddPdQ+       | j                  dRdSdTt        d
dU       | j                  dVdWddXdY+       | j                         }|j                  s|j                  | j                  dZ       |S )[zParse command line arguments.z4Render reStructuredText to the console with rich-rst)descriptionz	--versionversionz	%(prog)s )actionr1   pathPATH?Nzpath to file, or - for stdin)metavarnargsr.   helpz-cz--force-colorforce_color
store_truezforce color for non-terminals)destr2   r8   z-ez
--encodingencodingutf-8z"encoding for file (default: utf-8))r;   typer.   r8   z-wz--widthwidthz*width of output (default will auto-detect))r>   r;   r.   r8   z-hwz--html-width
html_width1675pxz&width of html output (default: 1675px)z-tz--code-theme
code_themer-   z&pygments code theme (default: monokai)z--show-line-numbersshow_line_numbersz show line numbers in code blocks)r2   r;   r8   z-Sz--save-htmlhtml_filenamez#export rendered output to HTML filez-rz--wrap	word_wrapz#enable word wrapping for long linesz-sz--soft-wrap	soft_wrapzenable soft wrapping modez-glz--guess-lexerguess_lexerz,guess lexer for code blocks without languagez-dlz--default-lexerdefault_lexerpythonz1default lexer if no lexer found (default: python)z-sez--show-errorsshow_errorsz'display reStructuredText parsing errorsz--admonition-styleadmonition_stylepanelcompactz0rendering style for admonitions (default: panel))r;   r>   r.   choicesr8   z--html-theme
html_themer,   z.color theme for HTML export (default: dracula)z--list-html-themeslist_html_themesz*list available HTML export themes and exitz-oz--outputoutputz1write plain-text output to FILE instead of stdoutz-dz--debugdebugzenable debug loggingz*the following arguments are required: PATH)argparseArgumentParseradd_argumentr   strintlist_HTML_THEMES
parse_argsrP   r3   error)parserargss     r   parse_argumentsr^   >   s   $$JF I;-?XY
+   ,   1   9   5   5    /	   2   2   (   ;   @   6   )$?   \"=   9	   @   #   D  TYY%6ABKr   c                  D
   t               } | j                  r9t        j                  t        j                         t
        j                  d       | j                  r t        t              D ]  }t        |        ydj                  d| j                        }t        | j                        xs t        | j                        }t        | j                   | j"                  |      }	 | j$                  dk(  r4t
        j                  d       t&        j(                  j+                         }n]t
        j                  d	| j$                          t-        | j$                  d
| j.                        5 }|j+                         }ddd       	 t
        j                  d       t;        | j<                  | j>                  | j@                  | jB                  | jD                  | j$                  dk7  r| j$                  nd| jF                        }	 | j                  rt
        j                  d| j                          |j                  || jN                         |jQ                         }	t-        | j                  dd      5 }
|
jS                  |	       ddd       n|j                  || jN                         | j                  rdt
        j                  d | j                          t        jU                  | jV                  tX              }|j[                  | j                  ||!       y# 1 sw Y   xY w# t0        $ rl}|j                  t3        t5        d| j$                  d|j6                   d      dd             | j                  rt
        j9                  d       Y d}~yd}~ww xY w# tH        $ rj}|j                  t3        t5        dtK        |      jL                   d|       dd             | j                  rt
        j9                  d       Y d}~yd}~ww xY w# 1 sw Y   vxY w# t0        $ ry}|j                  t3        t5        d"| j                  xs | j                  d|j6                         d#d             | j                  rt
        j9                  d$       Y d}~yd}~wtH        $ rj}|j                  t3        t5        d%tK        |      jL                   d|       d&d             | j                  rt
        j9                  d'       Y d}~yd}~ww xY w)(zMain entry point.)levelzDebug mode enabledr   a[  <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
{stylesheet}
body {{
    color: {foreground};
    background-color: {background};
    max-width: HTML_WIDTH_PLACEHOLDER
}}
pre {{
    white-space: pre-wrap;
    white-space: -moz-pre-wrap;
    white-space: -pre-wrap;
    white-space: -o-pre-wrap;
    word-wrap: break-word;
}}
::-moz-selection {{
  background: #44475a;
}}
::selection {{
  background: #44475a;
}}
</style>
</head>
<body>
    <pre style="font-family:ui-monospace,'Fira Code',Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code>{code}</code></pre>
</body>
</html>
HTML_WIDTH_PLACEHOLDER)force_terminalr?   record-zReading from stdinzReading file: rt)r<   Nz/[bold red]Error reading file[/bold red]

Path: z	
Reason: z:

Check that the file exists and you have read permission.z[bold]File Error[/bold]red)titlestylezFile read error   zParsing reStructuredTextz<stdin>)rB   rC   rG   rH   rJ   filenamerK   z=[bold red]Error parsing reStructuredText[/bold red]

[yellow]z[/yellow]: z[bold]Parse Error[/bold]zParse errorzWriting output to: )rF   wr=   zExporting HTML to: )themecode_formatz1[bold red]Error writing output[/bold red]

Path: z[bold]Output Error[/bold]zOutput write errorz2[bold red]Error during export[/bold red]

[yellow]z[bold]Export Error[/bold]zExport error).r^   rR   loggingbasicConfigDEBUGlogrP   sortedrY   printreplacer@   boolrD   rQ   r   r9   r?   r3   sysstdinreadopenr<   OSErrorr   r   strerror	exceptionr   rB   rC   rG   rH   rJ   rK   	Exceptionr>   __name__rF   export_textwritegetrO   _DRACULA_TERMINAL_THEME	save_html)r]   namehtml_formatrc   consolecodefile_handleersttext_outputout_fhrO   s               r   mainr      s:   Dzz'--0		&'<(D$K )	@ g&8C F $$$%:dkk):FT%5%5TZZPVWG99II*+99>>#DIItyyk23dii>+"'') ?&		,-"44((,,(("&))s"2TYY	!22	
2,;;II+DKK=9:MM#M8!--/Kdkk39V[) :9 MM#M8II+D,>,>+?@A%))$//;RSJ""*+  B y ?> !YYM * zzl +OO 0		
 ::MM+,:  #Aw//0A3@ 1		
 ::MM-(( :9  ![[>D,>,>A B zzl,
 2
	
 ::MM./ #Aw//0A3@ 2		
 ::MM.)s   'BL1 .L$?L1 A?N) A3P, ;PBP, $L.)L1 1	N&:A"N!!N&)	P2A PPP)$P, ,	T5A/R))T5A TT__main__)!rS   rn   rv   typingr   rich.consoler   
rich.panelr   rich.terminal_themer   r   r   r	   r
   	rich.textr   rich.tracebackr   rich_rstr   r   	getLoggerr~   rq   rW   r   r   rY   	Namespacer^   r   exitr   r   r   <module>r      s     
       " 2g!3 3 3 5c3#7 
 (BOS#BBCRBSCcCcCcCcCc	 	BBCRBSCcCcCcCcCc	 4 '$%Q++ QhUc Up zICHHTV r   