
Senior citizens ke liye Tirth Yatra ka complete planning guide. Route, stay, travel, darshan, documents, safety aur comfort tips jaanein – Om Shiv Shankar Tirth Yatra ke saath.
from pathlib import Path
import html
import re
src = Path("/mnt/data/Pasted markdown.md")
text = src.read_text(encoding="utf-8")
lines = text.splitlines()
out = []
in_ul = False
in_ol = False
def inline(s):
# Convert markdown links and bold
s = re.sub(r'\[([^\]]+)\]\(([^)]+)\)', r'\1', s)
s = re.sub(r'\*\*([^*]+)\*\*', r'\1', s)
s = re.sub(r'(?\1', s)
return s
for raw in lines:
line = raw.strip()
if not line:
if in_ul:
out.append(""); in_ul = False
if in_ol:
out.append(""); in_ol = False
continue
m = re.match(r'^(#{1,6})\s+(.*)$', line)
if m:
if in_ul:
out.append(""); in_ul = False
if in_ol:
out.append(""); in_ol = False
level = len(m.group(1))
out.append(f"{inline(m.group(2))}")
continue
if line.startswith("- "):
if in_ol:
out.append(""); in_ol = False
if not in_ul:
out.append("
- "); in_ul = True
out.append(f"
- {inline(line[2:])} ") continue m = re.match(r'^\*\*(.*?)\*\*$', line) if m: if in_ul: out.append("
{m.group(1)}
") continue if in_ul: out.append(""); in_ul = False if in_ol: out.append(""); in_ol = False out.append(f"{inline(line)}
") if in_ul: out.append("") if in_ol: out.append("") body = "\n".join(out) doc = f""" Senior Citizens ke Liye Tirth Yatra Planning {body} """ dest = Path("/mnt/data/tirth_yatra_senior_citizens.html") dest.write_text(doc, encoding="utf-8") print(f"Created: {dest}")
