depot/third_party/nixpkgs/pkgs/by-name/do/doctoc/test-generates-valid-markdown/default.nix
Default email 83627f9931 Project import generated by Copybara.
GitOrigin-RevId: 2893f56de08021cffd9b6b6dfc70fd9ccd51eb60
2024-06-24 14:47:55 -04: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
''