
    Ng	                        U d dl mZ d dlmZmZ d dlZd dl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 ddZdZded<   	 	 	 	 	 	 dddZdS )    )annotations)IOAnyN)Element)FileType)exactly_one)get_last_modified_date)partition_htmlcontentsstr | bytesreturnstrc                Z    t          | t                    r|                     d          S | S )Nzutf-8)
isinstancebytesdecode)r   s    U/var/www/html/ai-engine/env/lib/python3.11/site-packages/unstructured/partition/md.pyoptional_decoder      s+    (E"" (w'''O    mdDETECTION_ORIGINfilename
str | NonefileIO[bytes] | Nonetexturlmetadata_filenamemetadata_last_modifiedkwargsr   list[Element]c           	        |d}t          | |||           | rt          |           nd}| Kt          | d          5 }t          |                                          }ddd           n# 1 swxY w Y   n|"t          |                                          }n~||t          j        |          }	|	j        st          d|	j	                   |	j
                            dd          }
|
                    d          st          d	|
 d
          |	j        }t          j        |dg          }t          d||p| t          j        |p|t"          d|S )a  Partitions a markdown file into its constituent elements

    Parameters
    ----------
    filename
        A string defining the target filename path.
    file
        A file-like object using "rb" mode --> open(filename, "rb").
    text
        The string representation of the markdown document.
    url
        The URL of a webpage to parse. Only for URLs that return a markdown document.
    metadata_last_modified
        The last modified date for the document.
    N )r   r   r   r   utf8)encodingzURL return an error: zContent-Typeztext/markdownz)Expected content type text/markdown. Got .tables)
extensions)r   r   metadata_file_typer   detection_origin )r   r	   openr   readrequestsgetok
ValueErrorstatus_codeheaders
startswithr   markdownr
   r   MDr   )r   r   r   r   r   r   r    last_modifiedfresponsecontent_typehtmls               r   partition_mdr<      s   0 | 4SAAAA8@J*8444dM(V,,, 	-"16688,,D	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 
	tyy{{++	<$${ 	MKX5IKKLLL'++NB??&&77 	KLKKK   }Txj999D +7x#;5F)    s   "A,,A03A0)r   r   r   r   )NNNNNN)r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r!   )
__future__r   typingr   r   r5   r.   unstructured.documents.elementsr   unstructured.file_utils.modelr   $unstructured.partition.common.commonr   &unstructured.partition.common.metadatar	   unstructured.partition.htmlr
   r   r   __annotations__r<   r+   r   r   <module>rE      s    " " " " " " "           3 3 3 3 3 3 2 2 2 2 2 2 < < < < < < I I I I I I 6 6 6 6 6 6           !$()-= = = = = = =r   