depot/pkgs/by-name/do/doctoc/test-generates-valid-markdown/default.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

14 lines
651 B
Nix

{ runCommandNoCC, doctoc }:
runCommandNoCC "doctoc-test-generates-valid-markdown.md" { nativeBuildInputs = [ doctoc ]; } ''
cp ${./input.md} ./target.md && chmod +w ./target.md
doctoc ./target.md
# Ensure that ./target.md changed
cmp --quiet ${./input.md} ./target.md && echo "doctoc-test-generates-valid-markdown: files unchanged, test fails" && exit 1
# Check for DocToc's default title
grep --fixed-strings '**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*' target.md
# Check for at least one Markdown anchor link
grep --extended-regexp '\- \[.*\]\(#[a-z-]*\)' target.md
cp target.md $out
''