>From 449dc8ab744b917a66ea1a38b7f5d7af09ba8025 Mon Sep 17 00:00:00 2001 From: Akira Yokosawa <akiyks@xxxxxxxxx> Date: Wed, 10 Aug 2016 06:59:07 +0900 Subject: [RFC PATCH 1/3] Trial of replacing hyphens with en-dashes for number ranges This commit adds scripts to do replacing. By doing "sh utilities/dohyphen2endash.sh" in the top directory, hyphens used in number ranges such as "Lines~m-n" will be replaced with en-dashes such as "Lines~m--n" in LaTeX sources. For patterns used to find replacement candidates, see "utilities/hyphen2endash.sh". Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx> --- utilities/dohyphen2endash.sh | 36 +++++++++++++++++++++++++++++++ utilities/hyphen2endash.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 utilities/dohyphen2endash.sh create mode 100644 utilities/hyphen2endash.sh diff --git a/utilities/dohyphen2endash.sh b/utilities/dohyphen2endash.sh new file mode 100644 index 0000000..3270983 --- /dev/null +++ b/utilities/dohyphen2endash.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Apply hypen2endash.sh for all .tex files +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you can access it online at +# http://www.gnu.org/licenses/gpl-2.0.html. +# +# Copyright (C) Akira Yokosawa, 2016 +# +# Authors: Akira Yokosawa <akiyks@xxxxxxxxx> + +texfiles=`find . -name '*.tex' -print` +for i in $texfiles +do + basename="${i%.tex}" +# echo $basename + sh ./utilities/hyphen2endash.sh $basename.tex > $basename.tmp + if diff -q $basename.tex $basename.tmp >/dev/null + then + rm $basename.tmp + else + echo "$basename.tex modified" + mv -f $basename.tmp $basename.tex + fi +done diff --git a/utilities/hyphen2endash.sh b/utilities/hyphen2endash.sh new file mode 100644 index 0000000..2b37696 --- /dev/null +++ b/utilities/hyphen2endash.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# +# Find hyphens used for number range and replace them with en dashes. +# +# Replacement candidates are +# Lines~nn-mm -> Lines~nn--mm +# Lines nn-mm -> Lines~nn--mm +# lines~nn-mm -> lines~nn--mm +# lines nn-mm -> lines~nn--mm +# line nn-mm -> lines~nn--mm -- includes typo fix +# Line nn-mm -> Lines~nn--mm -- includes typo fix +# line~nn-mm -> lines~nn--mm -- includes typo fix +# Line~nn-mm -> Lines~nn--mm -- includes typo fix +# Lines~nn--mm and oo-pp -> Lines~nn--mm and oo--pp +# Slides nn-mm -> Slides~nn--mm +# Figures~\ref{foo}-\ref{bar} -> Figures~\ref{foo}--\ref{bar} +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you can access it online at +# http://www.gnu.org/licenses/gpl-2.0.html. +# +# Copyright (C) Akira Yokosawa, 2016 +# +# Authors: Akira Yokosawa <akiyks@xxxxxxxxx> + +cat $1 | + sed -e 's/Lines~\([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ + -e 's/Lines \([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ + -e 's/lines~\([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ + -e 's/lines \([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ + -e 's/Line~\([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ + -e 's/Line \([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2/g' \ + -e 's/line~\([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ + -e 's/line \([0-9]\+\)-\([0-9]\+\)/lines~\1--\2/g' \ + -e 's/Lines~\([0-9]\+\)--\([0-9]\+\) and \([0-9]\+\)-\([0-9]\+\)/Lines~\1--\2 and \3--\4/g' \ + -e 's/Slides \([0-9]\+\)-\([0-9]\+\)/Slides~\1--\2/g' \ + -e 's/Figures~\(\\ref{.*}\)-\(\\ref{.*}\)/Figures~\1--\2/g' \ + -e 's/\/\* Lines~\([0-9]\+\)--\([0-9]\+\) \*\//\/\* Lines \1-\2 \*\//g' + +# Last pattern is to preserve "Lines n-m" in comments within code snippet -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe perfbook" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html