summaryrefslogtreecommitdiff
path: root/bin/mddelta.sh
blob: 7db89f1f8d12a368c187c2b378ce75861ad06c4a (plain)
  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2024 Jonas Smedegaard <dr@jones.dk
  3. #
  4. # SPDX-License-Identifier: GPL-3.0-or-later
  5. #
  6. # generate markdown-formatted word-based delta between two markdown files
  7. set -eu
  8. #dwdiff -A best -R -d ',.?:;[]()-_/' -W ' \t\n#' -w '<span style="color: red"><del>' -x '</del></span>' -y '<span style="color: green"><ins>' -z '</ins></span>' "$1" "$2"
  9. # annotate changes with both span and del/ins html tags
  10. # * only del/ins confuses markdown parsers around unnumbered lists
  11. # inspiration: https://stackoverflow.com/a/2384393/18619283
  12. set - --start-insert='<span style="color: green"><ins>' --stop-insert='</ins></span>' "$@"
  13. set - --start-delete='<span style="color: red"><del>' --stop-delete='</del></span>' "$@"
  14. # treat # as whitespace and other punctuation as delimiters
  15. set - --white-space=' \t\n#' --delimiters=',.?:;[]()-_/' "$@"
  16. # compact difference detection and representation
  17. set - --algorithm=best --repeat-markers "$@"
  18. #echo dwdiff "$@"
  19. exec dwdiff "$@"