fixed some things. and did some UI changes
This commit is contained in:
46
PyPost.py
46
PyPost.py
@@ -122,7 +122,10 @@ def render_markdown(md_path: Path):
|
||||
<title>{title}</title>
|
||||
<link rel="stylesheet" href="../css/main.css">
|
||||
<link rel="icon" type="image/x-icon" href="../css/favicon/favicon.ico">
|
||||
<script src="../js/post/normal.js"></script>
|
||||
<script src="../js/post/download.js" defer></script>
|
||||
<style>
|
||||
a {{ text-decoration: none; color: #0066cc; }}
|
||||
</style>
|
||||
</head>
|
||||
<body style="display:flex; flex-direction:column; min-height:100%; margin:0;">
|
||||
<main class="container" style="flex:1;">
|
||||
@@ -144,6 +147,8 @@ def render_markdown(md_path: Path):
|
||||
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(hash1.encode("utf-8")).decode("utf-8")}</i><br />
|
||||
<img src="../css/icons/magnifier.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 2 (<b>Windows-1252</b>)<i>:{base64.b64encode(hash2.encode("windows-1252")).decode("windows-1252")}</i><br />
|
||||
<img src="../css/icons/save.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
<a id="download-md">Download as Markdown</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>"""
|
||||
@@ -162,11 +167,11 @@ def render_markdown(md_path: Path):
|
||||
# Create parent directories if needed
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if obfuscate:
|
||||
out_path.write_text(obfuscated_html, encoding="utf-8")
|
||||
else:
|
||||
out_path.write_text(clean_html, encoding="utf-8")
|
||||
|
||||
# if obfuscate:
|
||||
# out_path.write_text(obfuscated_html, encoding="utf-8")
|
||||
# else:
|
||||
# out_path.write_text(clean_html, encoding="utf-8")
|
||||
out_path.write_text(clean_html, encoding="utf-8")
|
||||
Logger.log_debug(f"Rendered: {md_path} -> {out_path}")
|
||||
|
||||
def remove_html(md_path: Path):
|
||||
@@ -184,7 +189,6 @@ def initial_scan(markdown_dir: Path):
|
||||
|
||||
|
||||
def build_rust_parser() -> bool:
|
||||
"""Attempt to build the Rust parser using cargo."""
|
||||
fastmd_dir = ROOT / "fastmd"
|
||||
|
||||
if not fastmd_dir.exists():
|
||||
@@ -269,34 +273,6 @@ if __name__ == "__main__":
|
||||
else:
|
||||
Logger.log_warning("Using Python parser for all files")
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="Monitor markdown directory and convert to HTML with dynamic parser selection.")
|
||||
|
||||
# This stores True when passed, but means "no obfuscation"
|
||||
parser.add_argument(
|
||||
"--no-obfuscate",
|
||||
action="store_false",
|
||||
help="Disable HTML obfuscation."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--rust-threshold",
|
||||
type=int,
|
||||
default=500,
|
||||
help=f"Line count threshold for using Rust parser (default: {RUST_PARSER_THRESHOLD})"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Invert it to get the obfuscate flag
|
||||
obfuscate = not args.no_obfuscate
|
||||
|
||||
# Update threshold if specified
|
||||
RUST_PARSER_THRESHOLD = args.rust_threshold
|
||||
|
||||
Logger.log_obfuscation_info(f"Obfuscation is {obfuscate}",obfuscate)
|
||||
|
||||
initial_scan(MARKDOWN_DIR)
|
||||
event_handler = Handler()
|
||||
observer = Observer()
|
||||
|
||||
Reference in New Issue
Block a user