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

39 lines
4.7 KiB
Plaintext
Raw Normal View History

2024-12-12 19:58:26 +01:00
<EFBFBD>
2024-12-21 02:16:29 +01:00
%<25>egH<00><00>H<00>ddlZddlmZddlmZddlmZmZGd<05>d<06>Zy)<07>N)<01> BeautifulSoup)<01>render_markdown_with_jinja)<02> Environment<6E>FileSystemLoaderc<00>J<00>eZdZdZdedefd<04>Zdedefd<07>Zdeded efd
2024-12-12 19:58:26 +01:00
<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.
2024-12-21 02:16:29 +01:00
)<01>loaderN)r rr<00>env)<03>selfr r
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
2024-12-12 19:58:26 +01:00
<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.
2024-12-21 02:16:29 +01:00
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) rr<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><><00>|jjd<01>}|jtjj |<01>j <00>|<02><02>}tj|d<03><04>t|dd<06><07>5}t|d<08>}|jd <09>
<EFBFBD>}|j|<08>d d d <0B>td |<03><00><02>y #1swY<00>xYw) a?
2024-12-12 19:58:26 +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.
2024-12-21 02:16:29 +01:00
zcombined_template.html)rr+T)<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) rrr+r3<00>template<74> rendered_html<6D>output<75>soup<75> cleaned_htmls r<00>_generate_index_htmlz&MarkdownProcessor._generate_index_html8s<><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> <20>-<2D><1D>@<40>D<EFBFBD><1F>=<3D>=<3D>7<EFBFBD>=<3D>;<3B>L<EFBFBD> <12>L<EFBFBD>L<EFBFBD><1C> &<26>6<> <0E> <0B>K<EFBFBD>=<3D>)<29>*<2A> 6<> 5<>s <00>?0C<03>Cc<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
2024-12-12 19:58:26 +01:00
Run the Markdown processing workflow: one 'index.html' per category.
z
2024-12-21 02:16:29 +01:00
index.htmlN)r"<00>walkr r%r&r2rF)r<00>root<6F>dirs<72>_<> directory<72> category_pathr3r+s r<00>runzMarkdownProcessor.runPsz<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)
2024-12-12 19:58:26 +01:00
<EFBFBD>__name__<5F>
2024-12-21 02:16:29 +01:00
__module__<EFBFBD> __qualname__<5F>__doc__<5F>strr<00>listr2rFrN<00>rrrr sQ<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>0 Trr) r"<00>bs4r<00>app.services.markdown_renderr<00>jinja2rrrrUrr<00><module>rYs<00><01> <09><1D>C<>0<>ST<01>STr