B
    Åû_ì  ã               @   s”   d dl Z d dlZd dlZd dlZd dlZ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ejdiZG dd„ dejƒZe eƒ ¡ dS )é    Nz^(?mx)
          (?P<match>
          <lilypond(\s+(?P<options>.*?))?\s*:\s*(?P<code>.*?)\s*/>)zx(?msx)
          (?P<match>
          <lilypond\s*(?P<options>.*?)\s*>
          (?P<code>.*?)
          </lilypond\s*>)z‰(?mx)
          (?P<match>
          <lilypondfile\s*(?P<options>.*?)\s*>
          \s*(?P<filename>.*?)\s*
          </lilypondfile\s*>)z6(?smx)(?P<match>\s*(?!@c\s+)(?P<code><!--\s.*?!-->)\s)z‰(?mx)
          (?P<match>
          <musicxmlfile\s*(?P<options>.*?)\s*>
          \s*(?P<filename>.*?)\s*
          </musicxmlfile\s*>)z'(?x)(?P<match>(?P<code><pre>.*?</pre>))z,(?xs)(?P<match>(?P<code><pre>\s.*?</pre>\s))z%(?mx)(?P<match><lilypondversion\s*/>))ZlilypondZlilypond_blockZlilypond_fileZmultiline_commentZmusicxml_fileÚverbZverbatimZlilypondversionz,<lilypond %(options)s>
%(code)s
</lilypond>
z
 </a>
</p>z<p>
 <a href="%(base)s%(ext)s">zU
  <img align="middle"
       border="0"
       src="%(image)s"
       alt="%(alt)s">z:<p><tt><a href="%(base)s%(ext)s">%(filename)s</a></tt></p>z#<blockquote>
%(str)s
</blockquote>
z<pre>
%(verb)s</pre>z%(program_version)sc               @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚBookHTMLOutputFormatc             C   s:   t j | ¡ d| _d| _t| _t| _dddg| _	d| _
d S )NZhtmlz.htmlz.xmlz.htmlyz\s+)Ú	book_baseÚBookOutputFormatÚ__init__ÚformatZdefault_extensionÚHTML_snippet_resZsnippet_resÚHTML_outputÚoutputZhandled_extensionsZsnippet_option_separator)Úself© r   úk/home/gub/NewGub/gub/target/mingw/src/lilypond-git.sv.gnu.org--lilypond.git-stable-2.22/python/book_html.pyr   s   s    zBookHTMLOutputFormat.__init__c             C   s&   |r"t  d|¡}dd„ |D ƒ}|S g S )Nz-[-\w\.-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|\S+))?c             S   s   g | ]}t  d d|¡‘qS )z!^([^=]+=\s*)(?P<q>["'])(.*)(?P=q)z
\g<1>\g<3>)ÚreÚsub)Ú.0Zoptr   r   r   ú
<listcomp>€   s   z>BookHTMLOutputFormat.split_snippet_options.<locals>.<listcomp>)r   Úfindall)r   Zoption_stringZoptionsr   r   r   Úsplit_snippet_options|   s    z*BookHTMLOutputFormat.split_snippet_optionsc             C   s   d|kr|d S |S d S )Nz	--formatsz --formats=png r   )r   Úcmdr   r   r   Úadjust_snippet_command…   s    z+BookHTMLOutputFormat.adjust_snippet_commandc             C   s  d}|  ¡ }||d< tj |j¡|d< |j|d< ||  ||¡7 }tj|j	krrt
 | ¡ ¡|d< || jtj | 7 }tj|j	kr’| jtj d|i }|| jtj | 7 }x^| ¡ D ]R}t |¡}||d< tj |¡\|d< |d< |j	tj |d< || jtj | 7 }q°W || jtj | 7 }|S )	NÚ ÚbaseÚfilenameÚextr   ÚstrÚimageZalt)Zget_replacementsÚosÚpathÚbasenamer   r   Zoutput_print_filenameÚbook_snippetsÚVERBATIMZoption_dictr   Zverbatim_htmlZverb_lyr
   ÚQUOTEÚBEFOREZ
get_imagesÚcopyÚsplitextZALTÚOUTPUTÚAFTER)r   r   ÚsnippetÚsZrepr   Zrep1r   r   r   Úsnippet_output‹   s(    

z#BookHTMLOutputFormat.snippet_outputc             C   s   |   ||||¡S )N)Zrequired_files_png)r   r'   r   ZfullÚrequired_filesr   r   r   r*   £   s    z#BookHTMLOutputFormat.required_filesN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r)   r*   r   r   r   r   r   r   s
   		r   )r#   r   r   r   r   r   ZFILTERr&   r"   r%   ZPRINTFILENAMEr!   r    ZVERSIONr	   r   r   Zregister_formatr   r   r   r   Ú<module>   s8   
5