From a56aefd1084a8e245429907ddd2a907c758e7d8d Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 12 Jan 2026 14:30:07 -0600 Subject: [PATCH 1/5] STYLE: Remove repeated words. --- Latex/Insight.sty | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Latex/Insight.sty b/Latex/Insight.sty index 76160181..40c1eba9 100644 --- a/Latex/Insight.sty +++ b/Latex/Insight.sty @@ -1,5 +1,5 @@ % -% Insight.sty for the Insight documentation [works only with with Latex2e] +% Insight.sty for the Insight documentation [works only with Latex2e] % \NeedsTeXFormat{LaTeX2e}[1995/12/01] @@ -1079,7 +1079,7 @@ % Definition lists; requested by AMK for HOWTO documents. Probably useful -% elsewhere as well, so keep in in the general style support. +% elsewhere as well, so keep in the general style support. % \newenvironment{definitions}{% \begin{description}% From c5457bb309fbfaa1a749a6a4516ce3d1d6c3cd7c Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 12 Jan 2026 14:33:00 -0600 Subject: [PATCH 2/5] ENH: Remove all references and uses of PERL --- Latex/doubleWordCheck.pl | 17 ------- Latex/doubleWordCheck.py | 100 +++++++++++++++++++++++++++++++++++++++ TODO | 1 - 3 files changed, 100 insertions(+), 18 deletions(-) delete mode 100755 Latex/doubleWordCheck.pl create mode 100755 Latex/doubleWordCheck.py diff --git a/Latex/doubleWordCheck.pl b/Latex/doubleWordCheck.pl deleted file mode 100755 index f7cceec5..00000000 --- a/Latex/doubleWordCheck.pl +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl -# -# Script for searching for double words in the text -# -# Contributed by Hans Johnson, Iowa University -# This was one of the first examples in the Mastering Regular Expressions Book. -# There are several other gems like this in that book. -# - -$/ = ".\n"; -while (<>) { - next if !s/\b([a-z]+)((\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$4\e[m/ig; - s/^([^\e]*\n)+//mg; - s/^/$ARGV: /mg; - print; -} - diff --git a/Latex/doubleWordCheck.py b/Latex/doubleWordCheck.py new file mode 100755 index 00000000..dc4f9c18 --- /dev/null +++ b/Latex/doubleWordCheck.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +""" +Search for doubled words in text + +Behavior: +- Reads one or more files (or stdin if none). +- Processes input in "records" delimited by ".\n" (Perl: $/ = ".\n"). +- In each record, highlights a repeated word (case-insensitive) where the two + occurrences are separated by whitespace and/or simple HTML tags. +- Removes any leading lines that contain no escape characters. +- Prefixes each remaining line with ": ". +""" + +from __future__ import annotations + +import argparse +import re +import sys +from pathlib import Path + + +ESC = "\x1b" + +# Perl: s/\b([a-z]+)((\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$4\e[m/ig +DOUBLE_WORD_RE = re.compile( + r"\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)", + re.IGNORECASE, +) + +# Perl: s/^([^\e]*\n)+//mg +# Interpreted as: drop initial consecutive lines that contain no ESC. +LEADING_NO_ESC_LINES_RE = re.compile(r"^(?:[^\x1b]*\n)+", re.MULTILINE) + + +def highlight_double_words(record: str) -> str | None: + """ + Return transformed record if a double-word pattern is found; otherwise None. + """ + + def repl(m: re.Match[str]) -> str: + w1 = m.group(1) + sep = m.group(2) + w2 = m.group(3) # same text as group(1) as matched + return f"{ESC}[7m{w1}{ESC}[m{sep}{ESC}[7m{w2}{ESC}[m" + + new_record, n = DOUBLE_WORD_RE.subn(repl, record, count=1) + if n == 0: + return None + + new_record = LEADING_NO_ESC_LINES_RE.sub("", new_record, count=1) + return new_record + + +def iter_records(text: str, sep: str = ".\n"): + """ + Yield records split by the exact separator, including the separator (like Perl $/). + """ + start = 0 + while True: + idx = text.find(sep, start) + if idx == -1: + if start < len(text): + yield text[start:] + break + end = idx + len(sep) + yield text[start:end] + start = end + + +def process_stream(name: str, data: str, out) -> None: + for record in iter_records(data, sep=".\n"): + transformed = highlight_double_words(record) + if transformed is None: + continue + + # Perl: s/^/$ARGV: /mg => prefix each line + prefixed = re.sub(r"^", f"{name}: ", transformed, flags=re.MULTILINE) + out.write(prefixed) + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("files", nargs="*", help="Files to scan; if empty, read stdin.") + args = ap.parse_args() + + if not args.files: + data = sys.stdin.read() + process_stream("", data, sys.stdout) + return 0 + + for f in args.files: + p = Path(f) + data = p.read_text(encoding="utf-8", errors="replace") + process_stream(f, data, sys.stdout) + + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/TODO b/TODO index dcaf37f1..a6c3a1a8 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -Remove all references to perl PERL Get output images only produced in BINARY_DIR. -- (DONE) Have python code line extractor throw warning when lines are too long to print. From b451d10ffb2e7ae891d8c75396c747356eaab8e4 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 12 Jan 2026 14:33:24 -0600 Subject: [PATCH 3/5] ENH: Remove some completed TODO items. --- TODO | 8 -------- 1 file changed, 8 deletions(-) diff --git a/TODO b/TODO index a6c3a1a8..9e4fbf13 100644 --- a/TODO +++ b/TODO @@ -1,17 +1,9 @@ Get output images only produced in BINARY_DIR. --- (DONE) Have python code line extractor throw warning when lines are too long to print. --- Reduce line length in ITK proper -- Figure out which pictures need "flipping" and how to do that with imagemagik. -- Order all tex files in SoftwareGuide/Latex/*.tex to be ordered when listed with a ##-${filename} prefix. --- Re-order chapters -- Add "Remote Module documentation" -- Remove "CenteredTransforms" from all examples in book. --- Remove redundant information. --- Describe Modularization as part of a ITKv3->ITKv4 transition appendix --- Update Acknowledgments --- Test clean builds --- Support "USE_SYSTEM_ITK" ========================================================== This is a list of potential topics to be added to the Software Guide. From d6e48e535c8dbdaf01fd8c94478e0e3c2e30aa74 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 12 Jan 2026 19:37:31 -0600 Subject: [PATCH 4/5] ENH: Add escaped quote marks for latex document. --- .../DevelopmentGuidelines/CreateAModule.tex | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex b/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex index 5efbd094..e52ef9ad 100644 --- a/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex +++ b/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex @@ -1293,16 +1293,16 @@ \subsection{CMakeList.txt} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cmake} # When this module is loaded by an app, load OpenCV too. -set(ITKVideoBridgeOpenCV_EXPORT_CODE_INSTALL " -set(OpenCV_DIR \"${OpenCV_DIR}\") -find_package(OpenCV REQUIRED) -") -set(ITKVideoBridgeOpenCV_EXPORT_CODE_BUILD " -if(NOT ITK_BINARY_DIR) +set(ITKVideoBridgeOpenCV_EXPORT_CODE_INSTALL \" set(OpenCV_DIR \"${OpenCV_DIR}\") find_package(OpenCV REQUIRED) -endif() -") +\") +set(ITKVideoBridgeOpenCV_EXPORT_CODE_BUILD \" + if(NOT ITK_BINARY_DIR) + set(OpenCV_DIR \"${OpenCV_DIR}\") + find_package(OpenCV REQUIRED) + endif() +\") \end{minted} Finally, set the \code{\_SYSTEM\_INCLUDE\_DIRS} and From 5e3a8f223356947d312bcc7df184b032f5ae0281 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 12 Jan 2026 20:30:11 -0600 Subject: [PATCH 5/5] ENH: Update cmake_minimum_versions to 3.22.1 --- CMakeLists.txt | 4 ++-- SoftwareGuide/CMakeLists.txt | 6 +++--- SoftwareGuide/Examples/CMakeLists.txt | 4 ++-- SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1101d71..55a5a94c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.16.3") -set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.19.7") +set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.22.1") +set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.29.0") cmake_minimum_required(VERSION ${ITK_OLDEST_VALIDATED_POLICIES_VERSION}...${ITK_NEWEST_VALIDATED_POLICIES_VERSION} FATAL_ERROR) set(PRIMARY_PROJECT_NAME ITKSoftwareGuide) diff --git a/SoftwareGuide/CMakeLists.txt b/SoftwareGuide/CMakeLists.txt index aac6e5e5..9193c94f 100644 --- a/SoftwareGuide/CMakeLists.txt +++ b/SoftwareGuide/CMakeLists.txt @@ -24,14 +24,14 @@ # images, if not the images are expected to be present in the Art/ folder # in PNG/XFIG/JPEG/EPS format. # -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project(SoftwareGuide C) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH}) -find_package(ITK 4 REQUIRED) +find_package(ITK 5 REQUIRED) include(${ITK_USE_FILE}) set(PDF_QUALITY_LEVEL "Screen" CACHE STRING "PDF Quality. Options are: Screen, Printer, PrePress") diff --git a/SoftwareGuide/Examples/CMakeLists.txt b/SoftwareGuide/Examples/CMakeLists.txt index 8924b12e..7d2ac07b 100644 --- a/SoftwareGuide/Examples/CMakeLists.txt +++ b/SoftwareGuide/Examples/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project(Examples C) diff --git a/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex b/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex index e52ef9ad..67e1ce85 100644 --- a/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex +++ b/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex @@ -64,8 +64,8 @@ \subsection{CMakeLists.txt} contain \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cmake} -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project(MyModule)