generated from hjess/PythonTemplateProject
Lets test
This commit is contained in:
43
depricated/convert_markdown_to_html.py
Normal file
43
depricated/convert_markdown_to_html.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
from app.services.markdown_render import render_markdown_with_jinja
|
||||
|
||||
def process_markdown_files(input_dir: str, output_dir: str):
|
||||
"""
|
||||
Recursively process all Markdown files in the input directory,
|
||||
render them to HTML, and save them to the output directory.
|
||||
"""
|
||||
for root, _, files in os.walk(input_dir):
|
||||
for file in files:
|
||||
if file.endswith(".md"):
|
||||
input_file_path = os.path.join(root, file)
|
||||
|
||||
# Determine output file path (convert .md to .html)
|
||||
relative_path = os.path.relpath(input_file_path, input_dir)
|
||||
output_file_path = os.path.join(output_dir, os.path.splitext(relative_path)[0] + ".html")
|
||||
|
||||
# Ensure the output directory exists
|
||||
os.makedirs(os.path.dirname(output_file_path), exist_ok=True)
|
||||
|
||||
# Read Markdown content
|
||||
with open(input_file_path, "r", encoding="utf-8") as md_file:
|
||||
markdown_content = md_file.read()
|
||||
|
||||
# Render Markdown with Jinja2
|
||||
print(f"Processing: {input_file_path} -> {output_file_path}")
|
||||
rendered_html = render_markdown_with_jinja(markdown_content)
|
||||
|
||||
# Write the rendered HTML to the output file
|
||||
with open(output_file_path, "w", encoding="utf-8") as html_file:
|
||||
html_file.write(rendered_html)
|
||||
|
||||
print("Markdown processing complete!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Input directory containing Markdown files
|
||||
input_directory = "./data"
|
||||
|
||||
# Output directory where HTML files will be stored
|
||||
output_directory = "./data"
|
||||
|
||||
# Start the processing
|
||||
process_markdown_files(input_directory, output_directory)
|
||||
25
depricated/markdown_service.py
Normal file
25
depricated/markdown_service.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
from app.services.markdown_render import render_markdown_with_jinja
|
||||
|
||||
def process_markdown_files(input_dir: str, output_dir: str):
|
||||
"""
|
||||
Recursively process all Markdown files in the input directory,
|
||||
render them to HTML, and save them in the output directory.
|
||||
"""
|
||||
for root, _, files in os.walk(input_dir):
|
||||
for file in files:
|
||||
if file.endswith(".md"):
|
||||
input_file_path = os.path.join(root, file)
|
||||
relative_path = os.path.relpath(input_file_path, input_dir)
|
||||
output_file_path = os.path.join(output_dir, os.path.splitext(relative_path)[0] + ".html")
|
||||
|
||||
os.makedirs(os.path.dirname(output_file_path), exist_ok=True)
|
||||
|
||||
with open(input_file_path, "r", encoding="utf-8") as md_file:
|
||||
markdown_content = md_file.read()
|
||||
|
||||
print(f"Processing: {input_file_path} -> {output_file_path}")
|
||||
rendered_html = render_markdown_with_jinja(markdown_content)
|
||||
|
||||
with open(output_file_path, "w", encoding="utf-8") as html_file:
|
||||
html_file.write(rendered_html)
|
||||
13
depricated/mock_data.json
Normal file
13
depricated/mock_data.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"categories": [
|
||||
{"name": "SKAT", "path": "skat", "author": "Henrik"},
|
||||
{"name": "Skole", "path": "skole", "author": "Erika"},
|
||||
{"name": "Bolig", "path": "bolig", "author": "Henrik"},
|
||||
{"name": "Job", "path": "job", "author": "Henrik"}
|
||||
],
|
||||
"favorites": [
|
||||
{"name": "SKAT", "image": "images/pic07.jpg", "description": "Favorit Kategori"},
|
||||
{"name": "Skole", "image": "images/pic08.jpg", "description": "Skole information"},
|
||||
{"name": "Bolig", "image": "images/pic09.jpg", "description": "Bolig detaljer"}
|
||||
]
|
||||
}
|
||||
18
depricated/test_markdown_render.py
Normal file
18
depricated/test_markdown_render.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from app.services.markdown_render import MarkdownRenderer
|
||||
|
||||
# Initialize MarkdownRenderer
|
||||
renderer = MarkdownRenderer()
|
||||
|
||||
# Test Markdown input
|
||||
markdown_content = """
|
||||
{img-left-overlay: src=my-cat.png}
|
||||
{box: title=Test Box, content=This is a test.}
|
||||
{note: content=This is a note.}
|
||||
{warning: content=Be careful!}
|
||||
"""
|
||||
|
||||
# Render to HTML
|
||||
print("Rendering Markdown...")
|
||||
html_output = renderer.render(markdown_content)
|
||||
print("Rendered HTML:")
|
||||
print(html_output)
|
||||
Reference in New Issue
Block a user