#!/usr/bin/env python3 # A Python script to generate a single PDF document with all the tldr pages. It works by generating # intermediate HTML files from existing md files using Python-markdown, applying desired formatting # through CSS, and finally rendering them as PDF. There is no LaTeX dependency for generating the PDF. import os import sys import glob import re import markdown import argparse from weasyprint import HTML def main(loc, colorscheme): oslist = [] allmd = [] group = [] ap = [] # Checking correctness of path if not os.path.isdir(loc): print("Invalid directory. Please try again!", file = sys.stderr) sys.exit(1) # Writing names of all directories inside 'pages' to a list for os_dir in os.listdir(loc): oslist.append(os_dir) oslist.sort() # Required strings to create intermediate HTML files header = '
' if colorscheme != "basic": header += '\n' header += "\n" footer = "" title_content = "