2f6i ddlZddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z ddl mZmZmZmZej$dk\rddlmZnddlmZej$dk\rddlmZnddlmZdZdZd Zd Zd Zd Zd ZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0d Z1d!Z2d"Z3d#Z4d Z5d Z6d$d%d&d'd(d)d*d+d,d-d.d/ Z7d0Z8d1Z9Gd2d3Z:Gd4d5Z;d6efd:Z?Gd;d<Z@Gd=d>eZAGd?d@ZBdBdAZCy)CN) OrderedDict)IteratorListOptionalSetTupleUnion)SCHEMEadd_truecolor_style_rule get_stylespop_truecolor_styles))version) TypedDictr r%&'(/01Zadku─u├u┤u┴u┬u│u┘u┐u┌u└u┼) 0x710x740x750x760x770x780x6a0x6b0x6c0x6d0x6ea$\documentclass{scrartcl} \usepackage[utf8]{inputenc} \usepackage{fancyvrb} \usepackage[usenames,dvipsnames]{xcolor} %% \definecolor{red-sd}{HTML}{7ed2d2} %(hyperref)s \title{%(title)s} \fvset{commandchars=\\\{\}} \begin{document} \begin{Verbatim} %(content)s \end{Verbatim} \end{document} a %(title)s
%(content)s
c feZdZd dZd dZddedeeddfdZdeded ed eddf d Z de efd Z y)_StatereturnNc2d|_|jy)NF) inside_spanresetselfs ]/var/lib/jenkins/workspace/metta-wam/venv/lib/python3.12/site-packages/ansi2html/converter.py__init__z_State.__init__s  ct|_t|_t|_t |_t|_ t|_ tdf|_ tdf|_t |_yN)ANSI_INTENSITY_NORMAL intensityANSI_STYLE_NORMALstyleANSI_BLINK_OFFblinkANSI_UNDERLINE_OFF underlineANSI_CROSSED_OUT_OFF crossedoutANSI_VISIBILITY_ON visibilityANSI_FOREGROUND_DEFAULT foregroundANSI_BACKGROUND_DEFAULT backgroundANSI_NEGATIVE_OFFnegativer=s r?r<z _State.resetsK3+ ( 0316Mt5T6Mt5T. rA ansi_code parameterc|tttfvr||_y|tt fvr||_y|tttfvr||_ y|ttfvr||_ y|ttfvr||_y|t"t$fvr||_yt(|cxkr t*kr nn |df|_yt.|cxkr t0kr nn |df|_y|t2k(r ||f|_y|t4k(r |df|_yt6|cxkr t8kr nn |df|_yt<|cxkr t>kr nn |df|_y|t@k(r ||f|_y|tBk(r |df|_y|tDtFfvr||_$yyrC)%ANSI_INTENSITY_INCREASEDANSI_INTENSITY_REDUCEDrDrEANSI_STYLE_ITALICrFrGANSI_BLINK_SLOWANSI_BLINK_FASTrHrIANSI_UNDERLINE_ONrJrKANSI_CROSSED_OUT_ONrLrMrNANSI_VISIBILITY_OFFrOANSI_FOREGROUND_CUSTOM_MINANSI_FOREGROUND_CUSTOM_MAXrQ"ANSI_FOREGROUND_HIGH_INTENSITY_MIN"ANSI_FOREGROUND_HIGH_INTENSITY_MAXANSI_FOREGROUNDrPANSI_BACKGROUND_CUSTOM_MINANSI_BACKGROUND_CUSTOM_MAXrS"ANSI_BACKGROUND_HIGH_INTENSITY_MIN"ANSI_BACKGROUND_HIGH_INTENSITY_MAXANSI_BACKGROUNDrRANSI_NEGATIVE_ONrTrU)r>rVrWs r?adjustz _State.adjustss  $ " !  'DN ,.?@ @"DJ ?O^L L"DJ ,.@A A&DN .0DE E'DO -/BC C'DO '9 R8R R($/DO . 21 2 )$/DO / )()4DO 1 1($/DO '9 R8R R($/DO . 21 2 )$/DO / )()4DO 1 1($/DO +->? ?%DM@rArgbcdj|||}|tk(}t|||||||r ||f|_y||f|_y)Nz{:03d}{:03d}{:03d})formatrer rQrS)r>rVrmrnrorW is_foregrounds r?adjust_truecolorz_State.adjust_truecolorsR(// q! "_4   1aIN ()4DO()4DOrAc tg}dttdtdtddfd}dttdttttfdtdt dtddf d }|||j t|||jt|||jt|||jt|||jt|||j t"|j$t&k(}|||j(t*|d |||j,t.|d |S) Noutputvaluedefaultr9c<||k7rd|z}|j|yy)Nzansi%d)append)rurvrw css_classs r?append_unless_defaultz4_State.to_css_classes..append_unless_defaults%$u,  i( rAcolorrU neg_css_classc|\}}||k7r/|rdnd}| t|nd||fz}|j||zy|r|j|yy)Ninvansiz%d-%s)strry) rur|rwrUr}rvrWprefixcss_class_indexs r?append_color_unless_defaultz:_State.to_css_classes..append_color_unless_defaultsc % E9"*#,#4CJ7eYEW;W  f67 m,rAinv_backgroundinv_foreground)rrintrrboolrErDrGrFrIrHrKrJrMrLrOrNrUrkrQrPrSrR)r> css_classesr{rflip_fore_and_backgrounds r?to_css_classesz_State.to_css_classess3!#  )$s) )C )# )RV )  -I -hsm+, - -  -   -   -" k4>>;PQk4::7HIk4::~Fk4>>;MNk4??rrs r?r@zOSC_Link.__init__s rA)rrrrr@rrAr?rrsCstrArcharr9cPtt|}|tvr t|S|SrC)hexordVT100_BOX_CODES)rchar_hexs r?map_vt100_box_coders&3t9~H(0O(C?8 $MMrArc,|r|jdryy)N FT)endswith)rs r?_needs_extra_newliners 4==& rAc eZdZy) CursorMoveUpN)rrrrrAr?rrsrArcFeZdZUeed<eed<eed<eed<eeed<y) Attributesdark_bg line_wrap font_sizebodystylesN)rrrr__annotations__rrrrAr?rrs MON I HrArcleZdZdZ d!dededededededed ed ed ed ed dfdZded efdZded efdZ ded e ee effdZ dede ed e eeeeffdZdede eded e eeeffdZde eeeefd eeeeffdZ d"deded efdZ d#dededed efdZd efd Zy)$Ansi2HTMLConverterzConvert Ansi color codes to CSS+HTML Example: >>> conv = Ansi2HTMLConverter() >>> ansi = " ".join(sys.stdin.readlines()) >>> html = conv.convert(ansi) latexinlinerrrlinkifyescaped markup_linesoutput_encodingschemetitler9Nc R||_||_||_||_||_||_||_||_| |_| |_ | |_ |d|_ |rbtt|j|j|jD cgc]} | jjd| f!c} |_t#j$d|_t#j$d|_t#j$d|_t#j$d|_ycc} w)NF.z \(([B0])z\[([\d;:]*)([a-zA-z])z(((((https?|ftps?|gopher|telnet|nntp)://)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*\';/?#:@&=+$,A-Za-z0-9])+)([).!\';/?:,][\s])?)z\]8;;(.*?)(.*?)\]8;;)rrrrrrrrrrrhyperrefdictr klassstriprrecompilevt100_box_codes_progansi_codes_prog url_matcher osc_link_re) r>rrrrrrrrrrritems r?r@zAnsi2HTMLConverter.__init__$s   ""  (.    !+4<< UZZ%%c*D1DK%'JJ$?!!zz*GH:: >  ::&NOs $D$linect|ts|S|jr|jj d|S|jj d|S)Nz \\url{\1}z\1) isinstancerrrsub)r>rs r? do_linkifyzAnsi2HTMLConverter.do_linkifyPsK$$K ::##'' d; ;##$:DAArApartc|jr$d|_d|jd|jdSd|jd|jdS)NTz\href{z}{}z z)rrrr)r>rs r?handle_osc_linksz#Ansi2HTMLConverter.handle_osc_linksXs= :: DM+/88TYY? ? -1HHdii@@rArc t}j||}j|}t|}dtt t tfdtt ffd }t||}dj|}jrMjsAdjt|jdD cgc] \}} d|| fzc} }}||fScc} }w)Npartsr9c3K|D]_}t|tr%jrj|3|8t|trj |\|aywrC)rrrrrr)rrr>s r? _check_linksz4Ansi2HTMLConverter.apply_regex.._check_linksdsVdC(||"ood33" h///55JsA&A)rz%s)set _apply_regex_collapse_cursorlistrr rrrjoinrr enumeratesplit) r>r styles_used all_partsno_cursor_partsrrcombinedirs ` r? apply_regexzAnsi2HTMLConverter.apply_regex^s # %%dK8 // :/ U3=%9 : x} \/23775>   TZZyy$-X^^D-A#B47!TBH $$ s C& rc#<KjrOjr tg}n tgd}|jD]\}}j ||dt t ffd }dj|dt dt tt tfffd }t}|D]2} t| tr| j| ||Ed{4|jrjrdydyy7)w) N))&z&)z>r9c3 Kd}d}jjD]V}||j}|r|D]}t|n||j }|j ddk(}X|dyw)NrF0)rfinditerstartrendgroups)last_endbox_drawing_modematchtrailerrrr>s r?_vt100_box_drawingz;Ansi2HTMLConverter._apply_regex.._vt100_box_drawingsH$ 22;;DAx%++-8# '066!("M 99;#(<<>!#4#; Bxy/ !sBBrrc3Kd}jj|D]]}|||j}||jd}|jd}t |||j }_||dyw)Nrr)rrrrrr)rrrrrrr>s r? _osc_linkz2Ansi2HTMLConverter._apply_regex.._osc_linksH))2248x%++-8 llnQ'||~a(sD)) 99; 9xy/ !sBB r)rrritemsreplacerrrr rr8r_handle_ansi_coder;) r>rrspecialspatternspecialrrstaters `` r?rzAnsi2HTMLConverter._apply_regex{s << &r?&%-NN$4 ||GW5%5 "HSM "ww)+, "C "HU3=-A$B "dOD$) 11$ UKKK $   zz  LsC,D0D1*Drc #Kd}|jj|D]l}|||j|j}|j \}}|dvrA|dk(r t S t |}|jdd}|jdd}t ||k(rn? tjd |D cgc] } t| }} d} d } t|D]C\} } | | kr | tk(r| } | ttfvs' || d z}|t"k(}|rd nd }| |z} E| D|| d zd}|j$rd|_|j&rdnd|j)|s[d } t|D]\} } | | kr | ttfv} || d z}|t"k(}|t*k(}|r|r t-|| d z}| d z} n3|r/|r- |j/| || d z|| dz|| d z| d z} d}|j1| ||j$r|j&rdndd|_|j3}|s=|j5||j6r|j8j5t;|j&rY|Dcgc]C}|j8|j<dddk(r|j8|j<dd E}}d|dzn|Dcgc])}||j8vr|j8|j>+}}ddjA|zn9|j&rddjA|znddjA|zd|_o||dycc} w#t$r tg}YwxYw#t $rd }YwxYw#t $rd }Y)wxYw#t $rY\wxYw#t $rYlwxYwcc}wcc}ww)NrmMAATz:::z;;;z[;:]rrrFrrr)rWr|z\textcolor[HTML]{%s}{zz; z\textcolor{%s}{ z)!rrrrrrlenrrrr ValueErrorANSI_FULL_RESETrrerj IndexErrorANSI_256_COLOR_IDr;rr<ANSI_TRUECOLOR_IDrrsrlrupdaterrr kwlkwr)r>rrrrrparamscommand param_lenxlast_null_indexskip_after_indexrvx_bit_color_id is_256_colorshiftis_x_bit_color is_truecolorrWrrrGs r?rz$Ansi2HTMLConverter._handle_ansi_codesg))2248Ex%++-0 0yy{H$llnOFGe##~"n$K c2c2v;)+  +*,((66*BCQ#a&CC #O! !&)1(('&'O?O<<,)/A$25F#FL!-A1E'(5y$* *! 3 56$$(-E%zz! '  " !&)1((!"&H!H(%+AE]N .1BB -1BB !l!36va!e}3E ()1u$# !..va!e}fQUmVAE] ()1u$ $I Q) 49*<  ::I#O$)!..0K   { +{{ ""#7#9:::&1!;;u-11!4Q77B E*..q1!4E 3U1X==&1! DKK/ E*--E . %0@@@::,sxx /DDD-0EEE $E y9z89oMD +)* +&,)+,:"(%'N(&! !&! !.sB1P4N NN 5PN4BP#O+PO P&O(B)P-AO85P.O=4A$PNN1-P0N11P4 O?POP OPOP O%!P$O%%P( O51P4O55 Prcfg}|D]}|st|tr|r|j|rnt|dtst|dtrHd|dvrA|j|r/t|dtr&t|dtrd|dvrA|j ||S)z=Act on any CursorMoveUp commands by deleting preceding tokensrr)rrpoprrry)r>r final_partsrs r?rz#Ansi2HTMLConverter._collapse_cursor8s 35 D$ -OO%!{29";r?C8TUW=X OO% "{29";r?C8TUW=X    t $+.rAensure_trailing_newlinec|j|\}}|rt|r|dz }|j|j|j||d|_|j S)z,Load the contents of 'ansi' into this objectr)rrrrr)rrrrr_attrs)r>rrrrs r?preparezAnsi2HTMLConverter.prepareWs^ ''- f "';D'A DLD||   {{rAfullc |j|||sdS|jrt}nt}t |j |j |j}|dd}tfd|}|djttt|t|z|j|jd|j|j rdd zSdd zS) z :param ansi: ANSI sequence to convert. :param full: Whether to include the full HTML document or only the body. :param ensure_trailing_newline: Ensures that ``\n`` character is present at the end of the output. )rrNrcD|jjddvS)Nrr)rlstrip)eattrss r?z,Ansi2HTMLConverter.convert..}saggnnS)U8_rrr _template all_styles backgrounds used_stylesrs @r?convertzAnsi2HTMLConverter.convertks T;R S= ::'I&I dnndkkJ  !n  %(style)s rGr)rr$rr rrrr=s r?produce_headersz"Ansi2HTMLConverter.produce_headerssB? TYYCDLL$..$++NOC   rA) FFTTnormalFTFutf-8 ansi2htmlr)rF)TF)rrr__doc__rrr@rrrrrrrr rrr8rrrrrr)r+rrAr?rrs!"&!*P*P*P *P  *P  *P*P*P*P*P*P*P *PXBsBsBAXA#A %%c3s8m(<%:8 8 &)#h8 %X|34 58 tAA&)#hA7=A %\)* +AFeC<$?@A eCM" #@?D7; *MR  # EI  <  rArc ttj}td}t j t j}|jdddd||jdd d d d d |jdddd d d|jdddd d d|jdddd d d|jdddddd !|jd"d#d$d d d%|jd&d'd(d d d)|jd*d+d,d d d-|jd.d/d0d1d2d3|jd4d5d6d d d7|jd8d9d:d;dd:d;d?!|jd@dAdBdCd|dD|zE|jdFdGdHdIdJK|jtjdLdMtjjj j j"j$j&j(j*j,j.N }t1tj2dOrpt5tj2t6j8sHtj2j;}t7j<|j>dPt_dWdQt@dRt@dSdMffdT }jBr||jEdIUyMtGjHxs j }|jKdIjMtj2jO|d1V}||dIUyM)Xz $ ls --color=always | ansi2html > directories.html $ sudo tail /var/log/messages | ccze -A | ansi2html > logs.html $ task burndown | ansi2html > burndown.html r.)usagez-Vz --versionrz %(prog)s )actionrz-pz --partialpartialF store_truez8Process lines as them come in. No headers are produced.)destrwr2helpz-Lz--latexrz Export as LaTeX instead of HTML.z-iz--inlinerz)Inline style without headers or template.z-Hz --headersheaderszJust produce the