diff --git a/common/bin/todo_rollover b/common/bin/todo_rollover new file mode 100755 index 0000000..7cc7bc7 --- /dev/null +++ b/common/bin/todo_rollover @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# On-demand rollover of a todo note. +# By default copies yesterday's note to today, pruning finished work and retitling. +# Usage: todo_rollover [source_date] [target_date] +# source_date defaults to yesterday (YYYY-MM-DD) +# target_date defaults to today +# Set TODO_NOTES to override notes directory. +# Set TODO_PRUNE to override prune script. + +set -euo pipefail + +NOTES=${TODO_NOTES:-$HOME/docs/notes/todo} +PRUNE=${TODO_PRUNE:-$HOME/.local/lib/todo/prune.py} + +src_date=${1:-$(date -d yesterday +%Y-%m-%d)} +target_date=${2:-$(date +%Y-%m-%d)} + +src="$NOTES/$src_date.md" +dst="$NOTES/$target_date.md" + +if [[ ! -f $src ]]; then + echo "todo_rollover: source note $src not found" >&2 + exit 1 +fi + +if [[ -f $dst ]]; then + echo "todo_rollover: target $dst already exists, skipping (use --force to overwrite)" >&2 + echo " Existing target was created from a previous rollover. If you really want to replace it, remove it first." >&2 + exit 2 +fi + +mkdir -p "$NOTES" +tmp=$(mktemp) +trap 'rm -f "$tmp"' EXIT + +if [[ -x $PRUNE ]]; then + python3 "$PRUNE" "$src" > "$tmp" +else + # fallback: just copy + cp "$src" "$tmp" +fi + +# Retitle first line to target date, matching rollover.py behavior +# Only replace line 1 if it looks like a date heading +first_line=$(head -n1 "$tmp") +if [[ $first_line =~ ^#\ [0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then + sed -i "1s/.*/# $target_date/" "$tmp" +else + # prepend heading + printf "# %s\n\n" "$target_date" | cat - "$tmp" > "${tmp}.new" + mv "${tmp}.new" "$tmp" +fi + +# Preserve mode of source +mode=$(stat -c %a "$src") +cp -p "$src" "$dst" # to get mode +cat "$tmp" > "$dst" + +echo "todo_rollover: created $dst from $src_date.md (pruned)" diff --git a/common/md_to_pdf/base.css b/common/md_to_pdf/base.css new file mode 100644 index 0000000..32b3e40 --- /dev/null +++ b/common/md_to_pdf/base.css @@ -0,0 +1,441 @@ +/* md_to_pdf: structure and typography. All colour lives in themes/*.css. */ + +:root { + --font-body: "Bitstream Charter", "Charter", "Noto Serif", Georgia, serif; + --font-head: "Lato", "Noto Sans", "Helvetica Neue", sans-serif; + --font-mono: "JetBrainsMono Nerd Font Mono", "JetBrains Mono", "Fira Code", monospace; + --measure-leading: 1.55; +} + +@page { + size: letter; + margin: 0.9in 1in 0.9in 1in; + background: var(--bg); + + @top-right { + content: string(doctitle); + font-family: var(--font-head); + font-size: 7.5pt; + letter-spacing: 0.09em; + text-transform: uppercase; + color: var(--fg-faint); + vertical-align: bottom; + padding-bottom: 0.28in; + } + @bottom-right { + content: counter(page); + font-family: var(--font-head); + font-size: 8.5pt; + color: var(--fg-faint); + vertical-align: top; + padding-top: 0.3in; + } +} + +@page :first { + @top-right { content: none; } + @bottom-right { content: none; } +} + +html { + font-size: 10pt; + background: var(--bg); +} + +body { + margin: 0; + background: var(--bg); + color: var(--fg); + font-family: var(--font-body); + font-size: 1rem; + line-height: var(--measure-leading); + font-kerning: normal; + font-variant-numeric: oldstyle-num proportional-nums; + hyphens: auto; + text-align: justify; + text-justify: inter-word; + orphans: 2; + widows: 2; +} + +/* ---------- title block ---------- */ + +.title-block { + margin: 0 0 2.6rem; + padding-bottom: 1.1rem; + border-bottom: 2px solid var(--accent); + text-align: left; + hyphens: none; +} + +.doc-title { + string-set: doctitle content(text); + font-family: var(--font-head); + font-size: 2.35rem; + font-weight: 900; + line-height: 1.12; + letter-spacing: -0.021em; + color: var(--fg-strong); + margin: 0; + padding: 0; + border: 0; +} + +.doc-subtitle { + font-family: var(--font-head); + font-size: 1.16rem; + font-weight: 300; + line-height: 1.35; + color: var(--fg-muted); + margin: 0.55rem 0 0; +} + +.doc-meta { + font-family: var(--font-head); + font-size: 0.72rem; + font-weight: 600; + letter-spacing: 0.13em; + text-transform: uppercase; + color: var(--fg-faint); + margin: 1.05rem 0 0; + font-variant-numeric: normal; +} + +.doc-meta .sep { padding: 0 0.35em; color: var(--accent); } + +/* ---------- headings ---------- */ + +h1, h2, h3, h4, h5, h6 { + font-family: var(--font-head); + color: var(--fg-strong); + hyphens: none; + text-align: left; + break-after: avoid; + break-inside: avoid; + font-variant-numeric: normal; +} + +h1 { + font-size: 1.62rem; + font-weight: 800; + letter-spacing: -0.014em; + line-height: 1.2; + margin: 2.5rem 0 0.95rem; + padding-bottom: 0.34rem; + border-bottom: 1px solid var(--border); +} + +h2 { + font-size: 1.32rem; + font-weight: 700; + letter-spacing: -0.008em; + line-height: 1.25; + margin: 2rem 0 0.6rem; +} + +h3 { + font-family: var(--font-body); + font-size: 1.12rem; + font-style: italic; + font-weight: 700; + line-height: 1.3; + margin: 1.5rem 0 0.45rem; +} + +h4 { + font-size: 0.84rem; + font-weight: 700; + letter-spacing: 0.075em; + text-transform: uppercase; + color: var(--fg-muted); + margin: 1.3rem 0 0.35rem; +} + +h5, h6 { + font-size: 0.92rem; + font-weight: 600; + font-style: italic; + color: var(--fg-muted); + margin: 1.15rem 0 0.3rem; +} + +:is(h1, h2, h3, h4, h5, h6) > .header-section-number { + color: var(--accent); + font-weight: 600; + padding-right: 0.42em; +} + +/* ---------- flow ---------- */ + +p { margin: 0 0 0.82rem; } + +:is(h1, h2, h3, h4, h5, h6) + p { margin-top: 0; } + +main > :first-child { margin-top: 0; } + +a { + color: var(--accent); + text-decoration: none; + overflow-wrap: break-word; +} + +strong { font-weight: 700; color: var(--fg-strong); } +em { font-style: italic; } + +del { color: var(--fg-muted); } + +sup, sub { line-height: 0; font-size: 0.72em; } + +abbr { letter-spacing: 0.04em; } + +hr { + border: 0; + border-top: 1px solid var(--border); + width: 22%; + margin: 2rem auto; +} + +/* ---------- lists ---------- */ + +ul, ol { margin: 0 0 0.82rem; padding-left: 1.45rem; } +li { margin: 0.16rem 0; } +li > ul, li > ol { margin: 0.16rem 0 0.3rem; } + +ul { list-style: none; } +ul > li { position: relative; } +ul > li::before { + content: "\2013"; + position: absolute; + left: -1.1rem; + color: var(--accent); + font-weight: 700; +} +ul ul > li::before { content: "\00B7"; } +ul ul ul > li::before { content: "\2013"; opacity: 0.55; } + +ol { list-style: decimal; padding-left: 1.75rem; } +ol > li::marker { color: var(--accent); font-family: var(--font-head); font-weight: 600; font-size: 0.9em; } + +/* task lists */ +ul.task-list input[type="checkbox"] { display: none; } + +ul.task-list > li::before { + content: ""; + display: inline-block; + position: static; + width: 0.6em; + height: 0.6em; + margin: 0 0.5em 0 -1.1em; + border: 1.1px solid var(--fg-faint); + border-radius: 2px; +} + +ul.task-list > li:has(input:checked)::before { + background: var(--accent); + border-color: var(--accent); +} + +dl { margin: 0 0 0.82rem; } +dt { + font-weight: 700; + color: var(--fg-strong); + margin-top: 0.6rem; + hyphens: none; +} +dd { margin: 0.1rem 0 0.4rem 1.35rem; color: var(--fg-muted); } + +/* ---------- quotes ---------- */ + +blockquote { + margin: 1.1rem 0; + padding: 0.15rem 0 0.15rem 1.15rem; + border-left: 2.5px solid var(--quote-bar); + color: var(--quote-fg); + break-inside: avoid; +} + +blockquote > :last-child { margin-bottom: 0; } +blockquote blockquote { margin: 0.7rem 0; opacity: 0.88; } + +/* ---------- code ---------- */ + +code, kbd, samp { + font-family: var(--font-mono); + font-size: 0.855em; + font-variant-ligatures: none; + font-variant-numeric: lining-nums tabular-nums; +} + +:not(pre) > code { + background: var(--inline-code-bg); + color: var(--inline-code-fg); + font-size: 0.82em; + padding: 0.08em 0.3em; + border-radius: 3px; + overflow-wrap: break-word; +} + +pre { + background: var(--code-bg); + color: var(--code-fg); + border: 1px solid var(--code-border); + border-radius: 5px; + padding: 0.72rem 0.9rem; + margin: 1.05rem 0; + line-height: 1.48; + white-space: pre-wrap; + overflow-wrap: anywhere; + tab-size: 4; + hyphens: none; + text-align: left; + orphans: 2; + widows: 2; +} + +pre > code { + background: none; + padding: 0; + border-radius: 0; + font-size: 0.845rem; + color: inherit; +} + +/* pandoc highlight classes */ +pre code span.co, pre code span.do { color: var(--hl-comment); font-style: italic; } +pre code span.kw, pre code span.cf { color: var(--hl-keyword); font-weight: 600; } +pre code span.st, pre code span.ss, pre code span.vs, pre code span.ch, pre code span.sc { color: var(--hl-string); } +pre code span.dv, pre code span.bn, pre code span.fl { color: var(--hl-number); } +pre code span.fu { color: var(--hl-function); } +pre code span.dt, pre code span.at { color: var(--hl-type); } +pre code span.va { color: var(--hl-variable); } +pre code span.op { color: var(--hl-operator); } +pre code span.cn, pre code span.bu, pre code span.ex { color: var(--hl-builtin); } +pre code span.im, pre code span.pp { color: var(--hl-preproc); } +pre code span.an, pre code span.cv, pre code span.in { color: var(--hl-comment); } +pre code span.al, pre code span.er { color: var(--hl-error); font-weight: 600; } +pre code span.wa { color: var(--hl-error); font-style: italic; } + +/* ---------- tables ---------- */ + +table { + width: 100%; + border-collapse: collapse; + margin: 1.2rem 0; + font-size: 0.93rem; + font-variant-numeric: lining-nums tabular-nums; + hyphens: none; + text-align: left; + break-inside: auto; +} + +thead { display: table-header-group; } +tr { break-inside: avoid; } + +thead th { + font-family: var(--font-head); + font-size: 0.72rem; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--fg-muted); + background: var(--table-head-bg); + border-top: 1.4px solid var(--fg-faint); + border-bottom: 1.4px solid var(--fg-faint); + padding: 0.5rem 0.6rem; + vertical-align: bottom; +} + +tbody td { + padding: 0.42rem 0.6rem; + border-bottom: 1px solid var(--border-faint); + vertical-align: top; +} + +tbody tr:last-child td { border-bottom: 1.4px solid var(--fg-faint); } + +caption { + caption-side: bottom; + font-size: 0.85rem; + font-style: italic; + color: var(--fg-muted); + padding-top: 0.5rem; + text-align: left; +} + +/* ---------- figures ---------- */ + +img { max-width: 100%; height: auto; border-radius: 4px; } + +figure { + margin: 1.4rem 0; + text-align: center; + break-inside: avoid; +} + +figcaption { + font-size: 0.85rem; + font-style: italic; + color: var(--fg-muted); + margin-top: 0.5rem; + text-align: center; +} + +/* ---------- table of contents ---------- */ + +#TOC { + margin: 0 0 2.4rem; + padding: 0 0 1.4rem; + border-bottom: 1px solid var(--border); + hyphens: none; + text-align: left; + break-after: page; +} + +#TOC .toc-title { + font-family: var(--font-head); + font-size: 0.75rem; + font-weight: 700; + letter-spacing: 0.14em; + text-transform: uppercase; + color: var(--fg-faint); + margin: 0 0 0.85rem; +} + +#TOC ul { list-style: none; padding-left: 0; margin: 0; } +#TOC ul ul { padding-left: 1.15rem; } +#TOC li { margin: 0.14rem 0; } +#TOC li::before { content: none; } + +#TOC a { + color: var(--fg); + font-family: var(--font-head); + font-size: 0.9rem; +} + +#TOC > ul > li > a { font-weight: 700; } +#TOC ul ul a { color: var(--fg-muted); font-size: 0.85rem; } + +#TOC a::after { + content: leader(". ") target-counter(attr(href), page); + color: var(--fg-faint); + font-size: 0.82rem; + font-variant-numeric: lining-nums; +} + +/* ---------- footnotes ---------- */ + +.footnote-ref { text-decoration: none; color: var(--accent); font-weight: 600; } + +.footnotes { + margin-top: 2.4rem; + padding-top: 0.9rem; + border-top: 1px solid var(--border); + font-size: 0.87rem; + color: var(--fg-muted); +} + +.footnotes hr { display: none; } +.footnotes ol { padding-left: 1.45rem; } +.footnotes li::marker { color: var(--fg-faint); font-weight: 400; font-variant-numeric: lining-nums; } +.footnotes p { margin-bottom: 0.35rem; } +.footnotes .footnote-back { color: var(--fg-faint); font-weight: 400; padding-left: 0.3em; } diff --git a/common/md_to_pdf/template.html b/common/md_to_pdf/template.html new file mode 100644 index 0000000..c002517 --- /dev/null +++ b/common/md_to_pdf/template.html @@ -0,0 +1,61 @@ + + +
+ +$if(basehref)$ +$subtitle$
+$endif$ +$if(author)$ + +$else$ +$if(date)$ + +$endif$ +$endif$ +