
    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dgZdgZ G d de      Zy# e$ r  e j*                         ZY *w xY w)    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                 @    t         |           t               | _        y )N)super__init__r   _html_converter)self	__class__s    f/root/aria/tools/markitdown-venv/lib/python3.12/site-packages/markitdown/converters/_docx_converter.pyr   zDocxConverter.__init__$   s    ,    file_streamstream_infokwargsreturnc                     |j                   xs dj                         }|j                  xs dj                         }|t        v ryt        D ]  }|j                  |      s y y)N TF)mimetypelower	extensionACCEPTED_FILE_EXTENSIONSACCEPTED_MIME_TYPE_PREFIXES
startswith)r   r   r   r   r   r!   prefixs          r   acceptszDocxConverter.accepts(   sg      ((.B557 **0b779	001 	F""6*	 r   c                 d   t         Rt        t        j                  t	        |       j
                  dd            t         d   j                  t         d         |j                  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1"4j11%" (n$Q'
 JJ{D1	-k:2t##22##$6)LRR

 	
r   )r/   
__module____qualname____doc__r   r   r   r   boolr&   r
   r7   __classcell__)r   s   @r   r   r      sc    /   	
 
$

  
 	

 
!
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      ss    
 	    * ? 5 % P  * N  $9 4
M 4
  *'3<<>*s   A A)(A)