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

38 lines
4.5 KiB
Plaintext
Raw Normal View History

2024-12-12 19:58:26 +01:00
<EFBFBD>
Zg<5A> <00><00><<00>ddlZddlmZddlmZmZGd<04>d<05>Zy)<06>N)<01>render_markdown_with_jinja)<02> Environment<6E>FileSystemLoaderc<00>J<00>eZdZdZdedefd<04>Zdedefd<07>Zdeded efd
<EFBFBD>Zd <0B>Z y ) <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>F<00>||_tt|<02><00><01>|_y)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>F/home/hjess/PycharmProjects/LifeFaq/app/services/markdown_processor.py<70>__init__zMarkdownProcessor.__init__ s<00><00>#<23><04><0E><1E>&6<>}<7D>&E<>F<><04><08><00>directory_path<74>returnc
<00><><00>g}ttj|<01><00>D]<5D>}|jd<01>s<01>tjj ||<03>}t |dd<03><04>5}|j<00>}ddd<05>t<06>\}}|j|jdd<07>||jdd <09>|jd
d <0B>d <0C><04><00><>|S#1swY<00>axYw) 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>:<3A>n<EFBFBD>5<>6<>D<EFBFBD><13>}<7D>}<7D>U<EFBFBD>#<23><1E>G<EFBFBD>G<EFBFBD>L<EFBFBD>L<EFBFBD><1E><14>><3E> <09><19>)<29>S<EFBFBD>7<EFBFBD>;<3B>w<EFBFBD>'.<2E>|<7C>|<7C>~<7E>$<24><<3C>.H<01>HX<48>-Y<>*<2A> <20>(<28><19><0F><0F>$<24>L<EFBFBD>L<EFBFBD><17>*<2A>=<3D>/<2F>'<27>|<7C>|<7C>I<EFBFBD>r<EFBFBD>:<3A>&<26>l<EFBFBD>l<EFBFBD>8<EFBFBD>Y<EFBFBD>?<3F> !<12><13>7<>"<18><0F><<3C>;<3B>s <00>$C<05>C r*<00> output_filec<00>h<00>|jjd<01>}|jtjj |<01>j <00>|<02><02>}tj|d<03><04>t|dd<06><07>5}|j|<05>ddd<08>td |<03><00><02>y#1swY<00>xYw)
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>8<EFBFBD>(<28>(<28>)A<>B<><08> <20><0F><0F><14>'<27>'<27>"<22>"<22>><3E>2<>=<3D>=<3D>?<3F><1D>(<28>
<EFBFBD> <0A> <0B> <0B> <0B>N<EFBFBD>T<EFBFBD>2<> <11>+<2B>s<EFBFBD>W<EFBFBD> 5<><16> <12>L<EFBFBD>L<EFBFBD><1D> '<27>6<> <0A> <0B>K<EFBFBD>=<3D>)<29>*<2A>6<> 5<>s <00>?B(<03>(B1c<00>0<00>tj|j<00>D]t\}}}|D]i}tjj ||<04>}tjj |d<01>}|j |<05>}|s<01>W|j |||<06><00>k<00>vy)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.runKsz<00><00> <20>W<EFBFBD>W<EFBFBD>T<EFBFBD>^<5E>^<5E>4<>M<EFBFBD>D<EFBFBD>$<24><01>!<21> <09> "<22><07><07> <0C> <0C>T<EFBFBD>9<EFBFBD> =<3D> <0A> <20>g<EFBFBD>g<EFBFBD>l<EFBFBD>l<EFBFBD>=<3D>,<2C>G<> <0B> <20>D<>D<>]<5D>S<><08><1B><18>-<2D>-<2D>m<EFBFBD>X<EFBFBD>{<7B>S<>"<22>5rN)
<EFBFBD>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>strr<00>listr1r@rH<00>rrrrsQ<00><00><08>
G<01>#<23> G<01>c<EFBFBD> G<01><18>3<EFBFBD><18>4<EFBFBD><18><+<2B>3<EFBFBD>+<2B>$<24>+<2B>UX<55>+<2B>, Trr)r!<00>app.services.markdown_renderr<00>jinja2rrrrOrr<00><module>rRs<00><01> <09>C<>0<>QT<01>QTr