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

42 lines
5.2 KiB
Plaintext
Raw Normal View History

2025-01-14 17:25:45 +01:00
<EFBFBD>
<00><>_g<5F> <00><00>D<00>ddlZddlmZddlmZmZGd<04>d<05><00>ZdS)<06>N)<01>render_markdown_with_jinja)<02> Environment<6E>FileSystemLoaderc<00>L<00>eZdZdZdedefd<04>Zdedefd<07>Zdeded efd
<EFBFBD>Zd <0B>Z d S) <0A>MarkdownProcessorz<72>
A class to process Markdown files, extract metadata, and generate a single
'index.html' per category directory using a custom rendering engine.
<20> input_dir<69> templates_dirc<00>X<00>||_tt|<02><00><00><01><00>|_dS)z<>
Initialize the MarkdownProcessor.
Args:
input_dir (str): Root directory containing category subdirectories.
templates_dir (str): Directory containing Jinja2 templates.
)<01>loaderN)rrr<00>env)<03>selfrr s <20>L/Users/lrihni/IdeaProjects/Privat/LifeFaq/app/services/markdown_processor.py<70>__init__zMarkdownProcessor.__init__ s*<00><00>#<23><04><0E><1E>&6<>}<7D>&E<>&E<>F<>F<>F<><04><08><08><08><00>directory_path<74>returnc
<00><00>g}ttj|<01><00><00><00>D]<5D>}|<03>d<01><00>r<>tj<00>||<03><00>}t |dd<03><04><00>5}|<05><00><00>}ddd<05><00>n #1swxYwYt|<06><00>\}}|<02> |<08>
dd<07><00>||<08>
dd <09><00>|<08>
d
d <0B><00>d <0C><04><00><00><>|S) a
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.
z.md<6D>r<>utf-8<><01>encodingN<67>title<6C>Untitled<65>summary<72><00>author<6F>Unknown)<04>name<6D>contentrr) <0B>sorted<65>os<6F>listdir<69>endswith<74>path<74>join<69>open<65>readr<00>append<6E>get) r r<00>sections<6E>file<6C> file_path<74>md_file<6C>markdown_content<6E>rendered_content<6E>metadatas r<00>$_process_markdown_files_in_directoryz6MarkdownProcessor._process_markdown_files_in_directorys?<00><00><16><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<>.H<01>HX<48>-Y<>-Y<>*<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>-B<05>B <09>B r*<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}|<06> |<05><00>ddd<08><00>n #1swxYwYtd |<03><00><02><00>dS)
a?
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.
zcombined_template.html)rr*T)<01>exist_ok<6F>wrrNz Generated: ) r <00> get_template<74>renderr!r$<00>basename<6D>
capitalize<EFBFBD>makedirsr&<00>write<74>print)r rr*r2<00>template<74> rendered_html<6D>outputs r<00>_generate_index_htmlz&MarkdownProcessor._generate_index_html5s<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>
<EFBFBD>
<EFBFBD> <0A> <0B> <0B>N<EFBFBD>T<EFBFBD>2<>2<>2<>2<> <11>+<2B>s<EFBFBD>W<EFBFBD> 5<> 5<> 5<> (<28><16> <12>L<EFBFBD>L<EFBFBD><1D> '<27> '<27> '<27> (<28> (<28> (<28> (<28> (<28> (<28> (<28> (<28> (<28> (<28> (<28><><EFBFBD><EFBFBD> (<28> (<28> (<28> (<28> <0A>)<29>K<EFBFBD>)<29>)<29>*<2A>*<2A>*<2A>*<2A>*s<00> B+<03>+B/<07>2B/c<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
Run the Markdown processing workflow: one 'index.html' per category.
z
index.htmlN)r!<00>walkrr$r%r1r@)r <00>root<6F>dirs<72>_<> directory<72> category_pathr2r*s r<00>runzMarkdownProcessor.runKs<><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> TrN)
<EFBFBD>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>strr<00>listr1r@rH<00>rrrrs<><00><00><00><00><00><00><08><08>
G<01>#<23> G<01>c<EFBFBD> G<01> G<01> G<01> G<01><18>3<EFBFBD><18>4<EFBFBD><18><18><18><18><+<2B>3<EFBFBD>+<2B>$<24>+<2B>UX<55>+<2B>+<2B>+<2B>+<2B>, T<01> T<01> T<01> T<01> Trr)r!<00>app.services.markdown_renderr<00>jinja2rrrrOrr<00><module>rRs~<00><01> <09> <09> <09> <09>C<>C<>C<>C<>C<>C<>0<>0<>0<>0<>0<>0<>0<>0<>QT<01>QT<01>QT<01>QT<01>QT<01>QT<01>QT<01>QT<01>QT<01>QTr