29 lines
1006 B
Python
29 lines
1006 B
Python
from pathlib import Path
|
|
from watchdog.events import FileSystemEventHandler
|
|
|
|
# this has to be like this. idk why. its ass
|
|
|
|
class htmlhandler(FileSystemEventHandler):
|
|
def on_created(self, event):
|
|
if not event.is_directory and event.src_path.endswith(".md"):
|
|
import PyPost
|
|
PyPost.render_markdown(Path(event.src_path))
|
|
|
|
def on_modified(self, event):
|
|
if not event.is_directory and event.src_path.endswith(".md"):
|
|
import PyPost
|
|
PyPost.render_markdown(Path(event.src_path))
|
|
|
|
def on_deleted(self, event):
|
|
if not event.is_directory and event.src_path.endswith(".md"):
|
|
import PyPost
|
|
PyPost.remove_html(Path(event.src_path))
|
|
|
|
def on_moved(self, event):
|
|
src = Path(event.src_path)
|
|
dest = Path(event.dest_path)
|
|
import PyPost
|
|
if src.suffix.lower() == ".md":
|
|
PyPost.remove_html(src)
|
|
if dest.suffix.lower() == ".md":
|
|
PyPost.render_markdown(dest) |