
    :Qg	                        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y)    )annotations)IOAnyN)Element)FileType)exactly_one)get_last_modified_date)partition_htmlstrc                H    t        | t              r| j                  d      S | S )Nzutf-8)
isinstancebytesdecode)contentss    V/var/www/html/answerous/venv/lib/python3.12/site-packages/unstructured/partition/md.pyoptional_decoder      s     (E"w''O    mdDETECTION_ORIGINc           	        |d}t        | |||       | rt        |       nd}| 0t        | d      5 }t        |j	                               }ddd       n|t        |j	                               }n|t        j                  |      }	|	j                  st        d|	j                         |	j                  j                  dd      }
|
j                  d      st        d	|
 d
      |	j                  }t        j                  |dg      }t        d||xs | t        j                   |xs |t"        d|S # 1 sw Y   LxY w)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 )filenamefiletexturlutf8)encodingzURL return an error: zContent-Typeztext/markdownz)Expected content type text/markdown. Got .tables)
extensions)r   metadata_filenamemetadata_file_typemetadata_last_modifieddetection_origin )r   r	   openr   readrequestsgetok
ValueErrorstatus_codeheaders
startswithr   markdownr
   r   MDr   )r   r   r   r   r!   r#   kwargslast_modifiedfresponsecontent_typehtmls               r   partition_mdr7      sL   0 | 4SA8@*84dM(V, 	-"1668,D	- 	- 
	tyy{+	<<${{4X5I5I4JKLL''++NB?&&7;L>K  }}Txj9D +7x#;;5F)  +	- 	-s   D77E )r   zstr | bytesreturnr   )NNNNNN)r   
str | Noner   zIO[bytes] | Noner   r9   r   r9   r!   r9   r#   r9   r1   r   r8   zlist[Element])
__future__r   typingr   r   r/   r(   unstructured.documents.elementsr   unstructured.file_utils.modelr   $unstructured.partition.common.commonr   &unstructured.partition.common.metadatar	   unstructured.partition.htmlr
   r   r   __annotations__r7   r%   r   r   <module>rB      s    "    3 2 < I 6  #   !$()-==
= = 
	=
 "= '= = =r   