Skip to content

Instantly share code, notes, and snippets.

@lhitori
Created November 19, 2025 05:28
Show Gist options
  • Select an option

  • Save lhitori/84163f96d5f1d6368b7039796b09fdf2 to your computer and use it in GitHub Desktop.

Select an option

Save lhitori/84163f96d5f1d6368b7039796b09fdf2 to your computer and use it in GitHub Desktop.
que ça compile
import os, sys, time
class Watcher:
def __init__(self, path: str):
self.cont, self.prev_len, self.path = True, 0, path
def recompile(self) -> None:
cmd = (
"pandoc "
"--from markdown "
"--to pdf "
"--output %(path)s.pdf "
"--lua-filter /home/vik/.config/nvim/box.lua "
"%(path)s"
% {'path': self.path}
)
print("[~] Running command:", cmd)
os.system(cmd)
def watch(self) -> None:
while self.cont:
fd = open(self.path, "r")
try:
if (l := len(fd.read())) != self.prev_len:
self.prev_len = l
self.recompile()
except:
self.cont = False
fd.close()
time.sleep(1)
def main() -> int:
if len(sys.argv) != 2:
print("Veuillez spécifier un fichier.")
return 1
Watcher(sys.argv[1]).watch()
return 0
if __name__ == "__main__":
raise SystemExit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment