nix-conf/home/scripts/md2html.nix
danny 54ab4d4181 feat: yazi extra shortcuts
# Changes
## docs:
- Add extra tutorial docs
## Features:
- Add `pdf combine` to yazi
- Add `pdf normalization` to yazi
- Add `Markdown to html` to yazi
## Breaking Changes:
- Rename sops secret `wireguard/conf` to `wireguard/wg0.conf`: Make sure
update your `sops-conf.nix` and secrets file.
2025-10-01 15:14:19 +08:00

35 lines
895 B
Nix

{ pkgs, ... }:
let
cssStyle = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/xz/new.css/refs/heads/master/new.css";
hash = "sha256-Xd3AMZOeThsrupQusSLjqv3hbNmcpeTms0ieI9nyxOk=";
};
inlineHeader =
pkgs.writeText "pandoc-inline-header"
# html
''
<style>
h1 { font-size: 1.55em !important; }
h2 { font-size: 1.35em !important; }
h3 { font-size: 1.2em !important; }
h4 { font-size: 1.1em !important; }
</style>
'';
in
pkgs.writeShellScriptBin "md2html" ''
set -e
INPUT="$1"
shift
BASENAME="''\${INPUT%.*}"
HTML_TEMP="''\${BASENAME}.html"
PDF_OUTPUT="''\${BASENAME}.pdf"
${pkgs.pandoc}/bin/pandoc "$INPUT" -f markdown-implicit_figures \
--include-in-header=${inlineHeader} -s \
--to=html5 --embed-resources \
--css=${cssStyle} -o "$HTML_TEMP" "$@"
echo "generated: $HTML_TEMP"
''