From ffcd73854cf38ee2bc94a5f44c253f17b05d9a51 Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Fri, 7 Oct 2022 19:10:44 -0400 Subject: [PATCH] scripts: improve generated PDF bookmark layout (#8809) --- scripts/pdf/basic.css | 10 ++++++++++ scripts/pdf/render.py | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/pdf/basic.css b/scripts/pdf/basic.css index a81c5efce..52d794209 100644 --- a/scripts/pdf/basic.css +++ b/scripts/pdf/basic.css @@ -34,3 +34,13 @@ h1, h2, h4, ul { margin-top: 8.2em; font-size: 300%; } + +/* +The same is to have this look like a H1 tag, but we want the H2 tag so the +bookmarks list makes sense. +*/ +h2.title-page { + font-size: 2em; + margin-top: 0.67em; + margin-bottom: 0.67em; +} diff --git a/scripts/pdf/render.py b/scripts/pdf/render.py index 23fa8556f..53e00ebf6 100644 --- a/scripts/pdf/render.py +++ b/scripts/pdf/render.py @@ -10,7 +10,6 @@ through CSS, and finally rendering them as PDF. There is no LaTeX dependency for import os import sys import glob -import re import markdown import argparse from datetime import datetime @@ -34,10 +33,10 @@ def main(loc, colorscheme): html = ( '' + "

tldr pages

" - + "

Simplified and community-driven man pages

" - + "
Generated on " + + "
Simplified and community-driven man pages
" + + "
Generated on " + datetime.now().strftime("%c") - + "
" + + "" + '

' ) @@ -46,9 +45,9 @@ def main(loc, colorscheme): # Required string to create directory title pages html += ( - "

" + "

" + operating_sys.capitalize() - + "

" + + "" + '

' ) @@ -58,9 +57,12 @@ def main(loc, colorscheme): ): with open(md, "r") as inp: text = inp.readlines() + # modify our page to have an H2 header, so that it is grouped under + # the H1 header for the directory + text[0] = "

" + text[0][2:] + "

" for line in text: - if re.match(r"^>", line): - line = line[:0] + "####" + line[1:] + if line.startswith(">"): + line = "####" + line[1:] html += markdown.markdown(line) html += '

' print(f"Rendered page {page_number} of the directory {operating_sys}")