o
    f66                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZ	dde
d d dddd	d
ddd	ZejdejdejdejdejdejdejdiZddddddZdZdd ZedZG dd  d ejZee  dS )!    Nzw(?mx)
          ^
          (?P<match>
            @include
            \s+
            (?P<filename> \S+ )
          )z(?smx)
          ^
          [^\n]*? (?! @c \s+ ) [^\n]*?
          (?P<match>
            @lilypond
            \s*
            ( \[ \s* (?P<options> [^\[\]]*? ) \s* \] )?
            \s*
            { (?P<code>
   z) }
          )z(?smx)
          ^
          (?P<match>
            @lilypond
            \s*
            ( \[ \s* (?P<options> [^\[\]]*? ) \s* \] )?
            \s+?
            ^ (?P<code> .*? )
            ^ @end \s+ lilypond
          ) \sz(?mx)
          ^
          (?P<match>
            @lilypondfile
            \s*
            ( \[ \s* (?P<options> [^\[\]]*? ) \s* \] )?
            \s*
            { (?P<filename> \S+ ) }
          )z(?smx)
          ^
          (?P<match>
            (?P<code>
              @ignore
              \s .*?
              @end \s+ ignore
            )
          ) \sz(?mx)
          ^
          (?P<match>
            @musicxmlfile
            \s*
            ( \[ \s* (?P<options> [^\[\]]*? ) \s* \] )?
            \s*
            { (?P<filename> \S+ ) }
          )z(?mx)
          ^
          .*
          (?P<match>
            (?P<code>
              @c ( [ \t] [^\n]* | ) \n
            )
          )z(?sx)
          (?P<match>
            (?P<code>
              @example
              \s .*?
              @end \s+ example \s
            )
          )z[(?mx)
          [^@]
          (?P<match> @lilypondversion )
          [^a-zA-Z]
          )	ZincludeZlilypondZlilypond_blockZlilypond_fileZmultiline_commentZmusicxml_fileZsingleline_commentZverbatimZlilypondversionz,@lilypond[%(options)s]
%(code)s@end lilypondz0@iftex
@include %(base)s-systems.texi
@end iftexz@ifinfo
@image{%(info_image_path)s,,,%(alt)s}
@end ifinfo
@html
%(para_pre)s<a href="%(base)s%(ext)s">
  <img align="middle"
       border="0"
       src="%(image)s"
       alt="%(alt)s"></a>%(para_post)s
@end html
zU@html
<a href="%(base)s%(ext)s">
@end html
@file{%(filename)s}
@html
</a>
@end html

z!@quotation
%(str)s
@end quotationz @verbatim
%(verb)s@end verbatim
z%(program_version)sz160\mmz6.5\inz150\mmz5\in6\in)z@afourpaperz
@afourwidez@afourlatexz
@smallbookz@letterpaperz
\input texinfo
@setfilename Texinfo_width_test
@settitle Texinfo width test
%(preamble)s

@message{Global: textwidth=@the@hsize,exampleindent=@the@lispnarrowing}

dummy

@bye
c                 C   s  d }d}t || }|r|d}d}t || }|r!|d| d|}td|i }td\}}	t	j
|	d d }
t|d	d
d}|| |  ttd|	  d|j|
|	f }td|  t	j }d|d< d}tjdkrd}t }t	j
|d}|d| 7 }t	|}t|dd }|dkrttd t	| t	| n!tj|||dtj tj d}|! \}}|j"dkrttd|  t	#|	 t	j
$|
rt	#|
 d}t d|}|rt%|dd }|r|&drdt'|d d }nd t'|d }nt()|d!}d}t d"|}|r@t%|dd }|r8|&dr8dt'|d d }n
d t'|d }nd#}t*j+|t*j,|i}td$|  |S )%NzG(@(?:afourpaper|afourwide|afourlatex|afivepaper|smallbook|letterpaper))   z9(@(?:fonttextsize|pagesizes|cropmarks|exampleindent).*)\nr   
preamble.texiz.pdfwutf-8encodingz=Running texi2pdf on file %s to detect default page settings.
z%s --batch -c -o %s %szExecuting: %s
CLC_ALLTZmingw32Fz
output.txtz > %sutf8z(Unable to auto-detect default settings:
)envuniversal_newlinesshellstdoutstderrz*Unable to auto-detect default settings:
%sztextwidth=([0-9.]+)ptgzGR@z@afourz%g\mmgffffff9@   z%g\inr   zexampleindent=([0-9.]+)ptz0.4\inzAuto-detected values are: %s
)-researchgroupfindallinsertjoinTEXINFO_INSPECTION_DOCUMENTtempfileZmkstempospathsplitextopenwritecloselyZprogress_Ztexinfo_programZdebug_outputenvironcopysysplatformZmkdtempsystemreadZwarningremovermdir
subprocessPopenPIPEZcommunicate
returncodeunlinkexistsfloat
startswithroundtexinfo_line_widthsgetbook_snippetsZ
LINE_WIDTHZEXAMPLEINDENT)sourceglobal_optionsZpagesizeZtexinfo_paper_size_regexpmZrelevant_settings_regexpr   Ztexinfo_documentZhandleZtmpfileZoutfileZ
tmp_handlecmdZrun_envr   
output_dirZoutput_filenamer0   Zparameter_stringprocZerror_stringZ	textwidthvalZexampleindentZretval r@   a/home/lily/lilypond-2.24.4/release/binaries/mingw/lilypond/lilypond-2.24.4/python/book_texinfo.pyget_texinfo_width_indent   s   











rB   z!(?m)^@documentlanguage (.*?)( |$)c                   @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )BookTexinfoOutputFormatc                 C   s8   t j|  d| _d| _t| _t| _g d| _	d| _
d S )NZtexinfor   )z.itelyz.telyr   z.texinfoz\s*,\s*)	book_baseBookOutputFormat__init__formatZdefault_extensionTexInfo_snippet_resZsnippet_resTexInfo_outputoutputZhandled_extensionsZsnippet_option_separatorselfr@   r@   rA   rF   /  s   

z BookTexinfoOutputFormat.__init__c                 C   s   t j| |p
|dv S )N)z	texi-htmlZtexi)rD   rE   can_handle_format)rL   rG   r@   r@   rA   rM   8  s   z)BookTexinfoOutputFormat.can_handle_formatc                 C   s   |  | d S N)Zprocess_options_pdfnotdefault)rL   r:   r@   r@   rA   process_options<  s   z'BookTexinfoOutputFormat.process_optionsc                 C   s,   t |}|r|dds|dS dS )Nr   Zen )texinfo_lang_rer   r   r4   )rL   r9   r;   r@   r@   rA   get_document_language?  s   

z-BookTexinfoOutputFormat.get_document_languagec                 C   s*   t || j}| j| tj| | d S rN   )rB   r:   Zdefault_snippet_optionsupdaterD   rE   init_default_snippet_options)rL   r9   Ztexinfo_defaultsr@   r@   rA   rT   F  s
   z4BookTexinfoOutputFormat.init_default_snippet_optionsc                 C   sF   d|vr|d7 }d|vr!dg}| j js|d |dd| 7 }|S )Nz-dseparate-page-formatsz! -dseparate-page-formats=png,pdf z-dtall-page-formatsZepsZpngz -dtall-page-formats=%s ,)r:   Zskip_png_checkappendr   )rL   r<   Zformatsr@   r@   rA   adjust_snippet_commandL  s   
z.BookTexinfoOutputFormat.adjust_snippet_commandc                 C   s   d}|  }||d< tj|j|d< |j|d< tj|jvr'd|d< d|d< nd|d< d	|d< |	 D ]4}t

|}tj|d
 |d< ||d< |jtj |d< tj| jj|d |d< || jtj | 7 }q3|| jtj | 7 }|S )NrP   basefilenameextz<p>Zpara_prez</p>Z	para_postr   r   imageZaltZinfo_image_path)get_replacementsr   r   basenamerY   rZ   r8   INLINEoption_dictZ
get_imagesr&   r   ZALTr   r:   Zinfo_images_dirrJ   OUTPUTIMAGEOUTPUT)rL   r]   snippetsrepr[   Zrep1r@   r@   rA   output_infoY  s*   


z#BookTexinfoOutputFormat.output_infoc                    s   fdd}d}|}t j|jv r=|d }| j }||fD ]}||}	|	r<t|	ddd }|dd	}|d
| 7 } nqt j|jv ra|d }
|
 j }||
fD ]}||}	|	r`|d| 7 } nqP| ||7 }t j	|jvrs|d7 }d}|
 }t j|jv r| } jjrddlm} ||}n||d<  jt j | }| ||7 }t j|jv r jt j d|i }||7 }t j	|jvr|d7 }|S )Nc                    s&   t j jj| }t j|r|S dS )NrP   )r   r   r   r:   r=   r2   )fnprK   r@   rA   findy  s   z4BookTexinfoOutputFormat.snippet_output.<locals>.findrP   z	.doctitlerr	   r
   rU   z@comma{}z
@lydoctitle %s

z.texidocz@include %s


r   r   )highlight_lyZverbstr)r8   ZDOCTITLEr_   Zdocument_languager    r*   replaceZTEXIDOCZoutput_print_filenamer^   r\   VERBATIMZverb_lyr:   Z	highlightZauxiliar.book_highlightrj   rJ   re   QUOTE)rL   r]   rb   rh   rc   rX   ZdoctitleZtranslated_doctitletfullpathZtexidocZtranslated_texidocZsubstrrd   Zly_coderj   r@   rK   rA   snippet_outputx  sT   


z&BookTexinfoOutputFormat.snippet_outputc                 C   s   |  ||||S rN   )Zrequired_files_png)rL   rb   rX   Zfullrequired_filesr@   r@   rA   rr     s   z&BookTexinfoOutputFormat.required_filesN)__name__
__module____qualname__rF   rM   rO   rR   rT   rW   re   rq   rr   r@   r@   r@   rA   rC   .  s    	9rC   )r&   r   r   r-   r'   r   rD   r8   Zlilylibr#   Zbrace_matcherrH   ZFILTERra   r`   ZPRINTFILENAMErn   rm   ZVERSIONrI   r6   r   rB   compilerQ   rE   rC   Zregister_formatr@   r@   r@   rA   <module>   sV   


	[
0
f 