diff options
author | Jonas Smedegaard <dr@jones.dk> | 2024-11-24 14:03:27 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-11-24 14:03:27 +0100 |
commit | 61b0a9547822ad63957a13ff68843c4f578a46b8 (patch) | |
tree | 1ad1e71c1584fb81cd02323f43b2a80125ca6639 /bin/mddelta.sh | |
parent | 95f56989aa244fab4b39b06dfe7466c6338a44d6 (diff) |
add curriculum deltas
Diffstat (limited to 'bin/mddelta.sh')
-rwxr-xr-x | bin/mddelta.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/mddelta.sh b/bin/mddelta.sh new file mode 100755 index 0000000..7db89f1 --- /dev/null +++ b/bin/mddelta.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2024 Jonas Smedegaard <dr@jones.dk +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# generate markdown-formatted word-based delta between two markdown files + +set -eu + +#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" + +# annotate changes with both span and del/ins html tags +# * only del/ins confuses markdown parsers around unnumbered lists +# inspiration: https://stackoverflow.com/a/2384393/18619283 +set - --start-insert='<span style="color: green"><ins>' --stop-insert='</ins></span>' "$@" +set - --start-delete='<span style="color: red"><del>' --stop-delete='</del></span>' "$@" + +# treat # as whitespace and other punctuation as delimiters +set - --white-space=' \t\n#' --delimiters=',.?:;[]()-_/' "$@" + +# compact difference detection and representation +set - --algorithm=best --repeat-markers "$@" + +#echo dwdiff "$@" +exec dwdiff "$@" |