
    %j	                         d dl Z d dlZd dlmZ d dlmZmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZmZ dZ	 d dlZn# e$ r  e j                    ZY nw xY wdgZdgZ G d de          ZdS )    N)warn)BinaryIOAny   )HtmlConverter   )pre_process_docx)DocumentConverterResult)
StreamInfo)MissingDependencyExceptionMISSING_DEPENDENCY_MESSAGEzGapplication/vnd.openxmlformats-officedocument.wordprocessingml.document.docxc                   R     e Zd ZdZ fdZdedededefdZ	dededede
fdZ xZS )	DocxConverterzv
    Converts DOCX files to Markdown. Style information (e.g.m headings) and tables are preserved where possible.
    c                 n    t                                                       t                      | _        d S )N)super__init__r   _html_converter)self	__class__s    m/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/markitdown/converters/_docx_converter.pyr   zDocxConverter.__init__$   s+    ,    file_streamstream_infokwargsreturnc                     |j         pd                                }|j        pd                                }|t          v rdS t          D ]}|                    |          r dS dS )N TF)mimetypelower	extensionACCEPTED_FILE_EXTENSIONSACCEPTED_MIME_TYPE_PREFIXES
startswith)r   r   r   r   r   r!   prefixs          r   acceptszDocxConverter.accepts(   s      (.B5577 *0b7799	00041 	 	F""6** tt ur   c                 r   t           `t          t          j        t	          |           j        dd                    t           d                             t           d                   |                    dd           }t          |          } | j	        j
        t          j        ||          j        fi |S )Nr   docx)	converterr!   featurer   r   	style_map)r+   )_dependency_exc_infor   r   formattype__name__with_tracebackgetr	   r   convert_stringmammothconvert_to_htmlvalue)r   r   r   r   r+   pre_process_streams         r   convertzDocxConverter.convert:   s      +,*1"4jj1%"    (n$Q' 
 JJ{D11	-k::2t#2#$6)LLLR
 

 
 	
r   )r/   
__module____qualname____doc__r   r   r   r   boolr&   r
   r7   __classcell__)r   s   @r   r   r      s         / / / / /   	
 
   $

  
 	

 
!
 
 
 
 
 
 
 
r   r   )sysiowarningsr   typingr   r   r   r    converter_utils.docx.pre_processr	   _base_converterr
   _stream_infor   _exceptionsr   r   r,   r3   ImportErrorexc_infor#   r"   r    r   r   <module>rH      s4   



 				                       * * * * * * ? ? ? ? ? ? 5 5 5 5 5 5 % % % % % % P P P P P P P P  *NNNN * * *'3<>>* N  $9 4
 4
 4
 4
 4
M 4
 4
 4
 4
 4
s   ? AA