
On 3/5/25 02:21, Bruce Horrocks wrote:
On 4 Mar 2025, at 18:26, Pablo Rodriguez wrote:
The first line shows different versions text. I wonder whether there would be an automatic way to get the \inframed highlighting with any character that differs from the other column (it might be different, or just missing or being added).
I'm not aware of anything built-in.
[In short, my previous request intended how to have an automatic comparison of two versions from the same text automatically done.] Replying to this message from Bruce, I want to describe what I think it might do the job. Since I’m just an average computer user (my background is in humanities), I thank everyone for comments about whether this make sense (or not at all). Not being inclined to reinvent the wheel, after some searching I found out that "git diff" can do a char-level comparison between two texts: git diff -U1000 --color-words=. one.md two.md > one-two.diff [BTW, I use Markdown sources (which pandoc converts to XHTML and ConTeXt typesets them).] Since the output contains the coloring commands, I need some substitutions with: sed -E -f normal.sed one-two.diff > one-two_normal.diff The contents of the sed script read: s/(^[#]{2,3})\x1B\[m$/\1/g s/\x1B\[(36|1).+?\x1B\[m//g s/\x1B\[31m/\\Subs{/g s/\x1B\[32m/\\Add{/g s/\x1B\[m/}/g Basically, this script removes info that ConTeXt cannot handle and translates color codes to \Add and \Subst commands. This minimal sample: another te\Subs{x}\Add{s}t On the left page with the older text, it might have the commands: \protected\def\Add#1{} \definehighlight[Subs] [color=red] On the right page with the newer version, commands might read: \definehighlight[Adds] [color=green] \protected\def\Subst#1{} At least, this works with a minimal sample. Is this a feasible approach? I don’t need the most efficient solution, just one that I can handle and that just works. Many thanks in advance for your comments, Pablo