o cc+ @sddlZddlZddlZddlZddlZddlZddlZddlZdde dddddd d d d d Z ej dej dej dejdejdejdiZdZddZddZGdddejZeedS)Nzp(?smx) ^[^%\n]*? (?P \\input\s*{ (?P\S+?) })z(?smx) ^ [^%\n]*? (?P \\lilypond \s* ( \[ \s* (?P [^\[\]]*? ) \s* \] )? \s* { (?P z) } )a:(?smx) ^ [^%\n]*? (?P \\begin \s* (?P {lilypond} \s* )? ( \[ \s* (?P [^\[\]]*? ) \s* \] )? (?(env) | \s* {lilypond} ) (?P .*? ) ^ [^%\n]*? \\end \s* {lilypond} )z(?smx) ^ [^%\n]*? (?P \\lilypondfile \s* ( \[ \s* (?P [^\[\]]*? ) \s* \] )? \s* { (?P \S+? ) } )z(?smx) ^ [^%\n]*? (?P \\musicxmlfile \s* ( \[ \s* (?P [^\[\]]*? ) \s* \] )? \s* { (?P \S+? ) } )zS(?mx) ^.*? (?P (?P %.*$\n+))z(?mx) ^[^%\n]*? (?P (?P \\verb(?P.) .*? (?P=del)))z(?msx) ^[^%\n]*? (?P (?P \\begin\s*{verbatim} .*? \\end\s*{verbatim}))zA(?smx) (?P \\lilypondversion)[^a-zA-Z]) ZincludeZlilypondZlilypond_blockZ lilypond_fileZ musicxml_fileZsingleline_commentverbZverbatimZlilypondversionz5\begin{lilypond}[%(options)s] %(code)s \end{lilypond}z{%% \parindent 0pt \noindent \ifx\preLilyPondExample \undefined \else \expandafter\preLilyPondExample \fi \def\lilypondbook{}%% \input{%(base)s-systems.tex}%% \ifx\postLilyPondExample \undefined \else \expandafter\postLilyPondExample \fi }z!\texttt{%(filename)s} \linebreak z!\begin{quote} %(str)s \end{quote}z1\noindent \begin{verbatim}%(verb)s\end{verbatim} z%(program_version)sz \nonstopmode %(preamble)s \begin{document} \typeout{textwidth=\the\textwidth} \typeout{columnsep=\the\columnsep} \makeatletter\if@twocolumn\typeout{columns=2}\fi\makeatother \end{document} cCs&d}td|}|durttd|S|d|d}td|i}td\}}t j |d}t j |d}|d} |d } t |d } | || ttd |j|fd |j|f} td | t j} d| d<t j j|j| ddf| d<d}tjdkrd}t}t j |d}| d|7} t jd}| dt jd<t | }|r|t jd<nt jd=t|dd}|dkrttdt |t |n!t!j"| | |dt!j#t!j#d}|$\}}|j%dkrttd|t &|t j '| r t &| t j '| r!t| dd}t &| d}td|}|r3t(|)d}d}td|}|rEt*|)d}td|}|rVt*|)d}n ttd|Std td!|td"|td#||r|r|||}td$td#||S)%Ng0@z"(?P\\begin\s*{document})z.cannot find \begin{document} in LaTeX documentrpreamble.texz.auxz.logwz;Running `%s' on file `%s' to detect default page settings. z%s %szExecuting: %s CLC_ALLZ TEXINPUTSTZmingw32Fz output.txtz > %sutf8)encodingz(Unable to auto-detect default settings: )envuniversal_newlinesshellstdoutstderrz*Unable to auto-detect default settings: %szcolumns=([0-9.]+)zcolumnsep=([0-9.]+)ptztextwidth=([0-9.]+)ptz"cannot detect textwidth from LaTeXzDetected values:z columns = %sz columnsep = %sz textwidth = %szAdjusted value:)+researchlyZwarning_startLATEX_INSPECTION_DOCUMENTtempfileZmkstempospathsplitextsplitfdopenwritecloseZprogressZ latex_programZ debug_outputenvironcopypathsepjoinZ input_dirgetsysplatformZmkdtempsystemopenreadremovermdir subprocessPopenPIPEZ communicate returncodeunlinkexistsintgroupfloat)sourceglobal_options textwidthmrZlatex_documentZhandleZtmpfileZ tmpfilerootZauxfileZlogfileZ tmp_handlecmdZrun_envrZ output_dirZoutput_filenameZ oldtexinputsr/Zparameter_stringprocZ error_stringcolumnsZ columnsepr<Y/home/lily/lilypond-2.24.1/release/binaries/lilypond/lilypond-2.24.1/python/book_latex.pyget_latex_textwidths                           r>cCs@|}td|rtd|stdd|}||_dSdSdS)N\\begin *{document}z {graphic[sx]z\\begin{document}z(\\usepackage{graphics} \\begin{document})replacement_textrrsubZ override_text)chunksr<r<r=modify_preamble%s   rDc@s<eZdZddZddZddZddZd d Zd d Zd S)BookLatexOutputFormatcCs>tj|d|_d|_t|_t|_gd|_ d|_ d|_ dS)NZlatexr)z.latexz.lytexrZpsz\s*,\s*) book_baseBookOutputFormat__init__formatZdefault_extensionLatex_snippet_resZ snippet_res Latex_outputoutputZhandled_extensionsZ image_formatsZsnippet_option_separator)selfr<r<r=rH1s   zBookLatexOutputFormat.__init__cCs||dS)N)Zprocess_options_pdfnotdefault)rMr6r<r<r=process_options;sz%BookLatexOutputFormat.process_optionscCst||j}d|S)Nz%.0f\pt)r>r6)rMr5r7r<r<r=get_line_width>s z$BookLatexOutputFormat.get_line_widthc CsVztjd|gddtjddj}|d}W|Stjtfy*tj ||}Y|Sw)NZ kpsewhichTzutf-8)Zcheckr rr ) r,runr.rstripZCalledProcessErrorFileNotFoundErrorrFrGinput_fullname)rMZinput_filenamerTr<r<r=rTBs$  z$BookLatexOutputFormat.input_fullnamecCs4|D]}|rtd|rt||Sq|S)Nr?)Zis_plainrrr@rD)rMZchunkscr<r<r=process_chunksTsz$BookLatexOutputFormat.process_chunkscCsd}|}|dd|d<tj|jdd|d<|j|d<tj|j vr0||j tj|7}tj |j vrF| |d<||j tj |7}||j tj |7} tj|j vra|j tjd |i}|S) Nr \/basefilenameextrrrPz% str)Zget_replacementsreplacerrbasenamerZr[ book_snippets PRINTFILENAMEZ option_dictrLVERBATIMZverb_lyOUTPUTrcountljustQUOTE)rMr^ZsnippetrCZrepZbreaksr<r<r=snippet_output\s     z$BookLatexOutputFormat.snippet_outputN) __name__ __module__ __qualname__rHrNrOrTrVrfr<r<r<r=rE0s  rE)rrr,r%rrFr_ZlilylibrZ brace_matcherrJZFILTERrbr`reraZVERSIONrKrr>rDrGrEZregister_formatr<r<r<r=sD    \& g E