Files
LifeFaq/app/services/__pycache__/markdown_processor.cpython-311.pyc

56 lines
5.7 KiB
Plaintext
Raw Normal View History

2025-01-14 17:25:45 +01:00
<EFBFBD>
2025-02-10 14:28:05 +01:00
<00><><EFBFBD>g<EFBFBD><00><00>\<00>ddlZddlmZddlmZddlmZddlmZm Z Gd<06>d<07><00>Z
dS)<08>N)<01> BeautifulSoup)<01>FastAPI)<01>MarkdownRenderer)<02> Environment<6E>FileSystemLoaderc<00>R<00>eZdZdZddededefd<06>Zdedefd <09>Zded
ed efd <0C>Z d <0A>Z
dS)<0F>MarkdownProcessorz<72>
2025-01-14 17:25:45 +01:00
A class to process Markdown files, extract metadata, and generate a single
'index.html' per category directory using a custom rendering engine.
2025-02-10 14:28:05 +01:00
N<> input_dir<69> templates_dir<69>appc<00>f<00>||_tt|<02><00><00><01><00>|_||_dS)z<>
2025-01-14 17:25:45 +01:00
Initialize the MarkdownProcessor.
Args:
input_dir (str): Root directory containing category subdirectories.
templates_dir (str): Directory containing Jinja2 templates.
2025-02-10 14:28:05 +01:00
)<01>loaderN)r
rr<00>envr )<04>selfr
r r s <20>L/Users/lrihni/IdeaProjects/Privat/LifeFaq/app/services/markdown_processor.py<70>__init__zMarkdownProcessor.__init__s1<00><00>#<23><04><0E><1E>&6<>}<7D>&E<>&E<>F<>F<>F<><04><08><16><04><08><08><08><00>directory_path<74>returnc
<00>L<00>ddlm}g}ttj|<01><00><00><00>D]<5D>}|<04>d<03><00>r<>tj<00>||<04><00>}t|dd<05><06><00>5}|<06> <00><00>}ddd<07><00>n #1swxYwYt||j <00><08><00>}|<08> |<07><00>\} }
|<03> |
<EFBFBD>d d
<EFBFBD><00>| |
<EFBFBD>d d <0C><00>|
<EFBFBD>d d<0E><00>d<0F><04><00><00><>|S)a
2025-01-14 17:25:45 +01:00
Process all Markdown files in a directory using Markdown and Jinja2 custom tags.
Args:
directory_path (str): Path to the category directory.
Returns:
list: A list of processed sections containing metadata and rendered content.
2025-02-10 14:28:05 +01:00
r)<01>Pathz.md<6D>r<>utf-8<><01>encodingN)<02> file_pathr <00>title<6C>Untitled<65>summary<72><00>author<6F>Unknown)<04>name<6D>contentrr!)<0F>pathlibr<00>sorted<65>os<6F>listdir<69>endswith<74>path<74>join<69>open<65>readrr <00>render_markdown_with_jinja<6A>append<6E>get) rrr<00>sections<6E>filer<00>md_file<6C>markdown_content<6E>markdown_render<65>rendered_content<6E>metadatas r<00>$_process_markdown_files_in_directoryz6MarkdownProcessor._process_markdown_files_in_directorysj<00><00> !<21> <20> <20> <20> <20> <20><15><08><1A>2<EFBFBD>:<3A>n<EFBFBD>5<>5<>6<>6<> <13> <13>D<EFBFBD><13>}<7D>}<7D>U<EFBFBD>#<23>#<23> <13><1E>G<EFBFBD>L<EFBFBD>L<EFBFBD><1E><14>><3E>><3E> <09><19>)<29>S<EFBFBD>7<EFBFBD>;<3B>;<3B>;<3B>6<>w<EFBFBD>'.<2E>|<7C>|<7C>~<7E>~<7E>$<24>6<>6<>6<>6<>6<>6<>6<>6<>6<>6<>6<><36><EFBFBD><EFBFBD>6<>6<>6<>6<>"2<>Y<EFBFBD>4<EFBFBD>8<EFBFBD>"T<>"T<>"T<><0F>.=<3D>-W<>-W<>Zj<5A>-l<>-l<>*<2A> <20>(<28><19><0F><0F>$<24>L<EFBFBD>L<EFBFBD><17>*<2A>=<3D>=<3D>/<2F>'<27>|<7C>|<7C>I<EFBFBD>r<EFBFBD>:<3A>:<3A>&<26>l<EFBFBD>l<EFBFBD>8<EFBFBD>Y<EFBFBD>?<3F>?<3F> !<12>!<12><13><13><13><><18>s<00>3B<05>B <09>B r1<00> output_filec<00><><00>|j<00>d<01><00>}|<04>tj<00>|<01><00><00><00><00>|<02><02><00>}tj|d<03><04><00>t|dd<06><07><00>5}t|d<08><00>}|<07>
d <09>
<EFBFBD><00>}|<06> |<08><00>d d d <0B><00>n #1swxYwYtd |<03><00><02><00>d S) a?
2025-01-14 17:25:45 +01:00
Generate the index.html file for a category using the combined sections.
Args:
directory_path (str): Path to the category directory.
sections (list): List of processed Markdown content and metadata.
output_file (str): Path to save the generated index.html.
2025-02-10 14:28:05 +01:00
zcombined_template.html)rr1T)<01>exist_ok<6F>wrrz html.parser<65>html5)<01> formatterNz Generated: ) r<00> get_template<74>renderr'r*<00>basename<6D>
capitalize<EFBFBD>makedirsr,r<00>prettify<66>write<74>print) rrr1r9<00>template<74> rendered_html<6D>output<75>soup<75> cleaned_htmls r<00>_generate_index_htmlz&MarkdownProcessor._generate_index_html;s%<00><00><18>8<EFBFBD>(<28>(<28>)A<>B<>B<><08> <20><0F><0F><14>'<27>"<22>"<22>><3E>2<>2<>=<3D>=<3D>?<3F>?<3F><1D>(<28>
2025-01-14 17:25:45 +01:00
<EFBFBD>
2025-02-10 14:28:05 +01:00
<EFBFBD> <0A> <0B> <0B>N<EFBFBD>T<EFBFBD>2<>2<>2<>2<> <11>+<2B>s<EFBFBD>W<EFBFBD> 5<> 5<> 5<> '<27><16> <20>-<2D><1D>@<40>@<40>D<EFBFBD><1F>=<3D>=<3D>7<EFBFBD>=<3D>;<3B>;<3B>L<EFBFBD> <12>L<EFBFBD>L<EFBFBD><1C> &<26> &<26> &<26> '<27> '<27> '<27> '<27> '<27> '<27> '<27> '<27> '<27> '<27> '<27><><EFBFBD><EFBFBD> '<27> '<27> '<27> '<27> <0E>)<29>K<EFBFBD>)<29>)<29>*<2A>*<2A>*<2A>*<2A>*s<00> <C<03>C<07>Cc<00>,<00>tj|j<00><00>D]y\}}}|D]p}tj<00>||<04><00>}tj<00>|d<01><00>}|<00>|<05><00>}|r|<00>|||<06><00><00>q<EFBFBD>zdS)zV
2025-01-14 17:25:45 +01:00
Run the Markdown processing workflow: one 'index.html' per category.
z
2025-02-10 14:28:05 +01:00
index.htmlN)r'<00>walkr
r*r+r8rL)r<00>root<6F>dirs<72>_<> directory<72> category_pathr9r1s r<00>runzMarkdownProcessor.runSs<><00><00> <20>W<EFBFBD>T<EFBFBD>^<5E>4<>4<> T<01> T<01>M<EFBFBD>D<EFBFBD>$<24><01>!<21> T<01> T<01> <09> "<22><07> <0C> <0C>T<EFBFBD>9<EFBFBD> =<3D> =<3D> <0A> <20>g<EFBFBD>l<EFBFBD>l<EFBFBD>=<3D>,<2C>G<>G<> <0B> <20>D<>D<>]<5D>S<>S<><08><1B>T<01><18>-<2D>-<2D>m<EFBFBD>X<EFBFBD>{<7B>S<>S<>S<><53> T<01> T<01> Tr)N) <0B>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>strrr<00>listr8rLrT<00>rrr r s<><00><00><00><00><00><00><08><08>
<17>
<17>#<23>
<17>c<EFBFBD>
<17>g<EFBFBD>
<17>
<17>
<17>
<17><18>3<EFBFBD><18>4<EFBFBD><18><18><18><18>@+<2B>3<EFBFBD>+<2B>$<24>+<2B>UX<55>+<2B>+<2B>+<2B>+<2B>0 T<01> T<01> T<01> T<01> Trr ) r'<00>bs4r<00>fastapir<00>app.services.markdown_renderr<00>jinja2rrr r[rr<00><module>r`s<><00><01> <09> <09> <09> <09><1D><1D><1D><1D><1D><1D><1B><1B><1B><1B><1B><1B>9<>9<>9<>9<>9<>9<>0<>0<>0<>0<>0<>0<>0<>0<>WT<01>WT<01>WT<01>WT<01>WT<01>WT<01>WT<01>WT<01>WT<01>WTr