texlive[66681] trunk: match_parens doc

commits+karl at tug.org commits+karl at tug.org
Mon Mar 27 00:26:59 CEST 2023


Revision: 66681
          http://tug.org/svn/texlive?view=revision&revision=66681
Author:   karl
Date:     2023-03-27 00:26:59 +0200 (Mon, 27 Mar 2023)
Log Message:
-----------
match_parens doc

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/match_parens/match_parens
    trunk/Master/texmf-dist/doc/support/match_parens/match_parens.pdf
    trunk/Master/texmf-dist/scripts/match_parens/match_parens
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/man/man1/match_parens.1
    trunk/Master/texmf-dist/doc/man/man1/match_parens.man1.pdf
    trunk/Master/texmf-dist/doc/support/match_parens/README.md

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/support/match_parens/README

Modified: trunk/Build/source/texk/texlive/linked_scripts/match_parens/match_parens
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/match_parens/match_parens	2023-03-26 20:40:32 UTC (rev 66680)
+++ trunk/Build/source/texk/texlive/linked_scripts/match_parens/match_parens	2023-03-26 22:26:59 UTC (rev 66681)
@@ -1,9 +1,10 @@
 #!/usr/bin/env ruby
 # encoding: utf-8
 
- MYNAME = File.basename($0)
-Version = '1.43'
+ Myname = File.basename($0)
+Version = '1.44'
 
+Help=
 <<'DOC'
 = match_parens - find mismatches of various brackets and quotes
 
@@ -10,12 +11,13 @@
 = Synopsis
 match_parens [filename]	
 
-Options:
--p,--pairs=S	set matching pairs to S (default: |{}[]()""“”''‘’|)
+== Options
+-h		print this help and exit
+-H,--help	print full documentation and exit
+-V,--version	print version and exit
+-l,--latex	convert ``...'' to “...” before testing
 -n,--number=N	set number of mismatching characters shown to N (default: 10)
--l,--latex	convert |``...''| to |“...”| before testing
--V,--version	print version and exit
--h,--help	print short help information and exit
+-p,--pairs=S	set matching pairs to S (default: {}[]()""“”''‘’)
    --test	do an internal test and exit
 
 = Description
@@ -45,23 +47,26 @@
 |</html>| or |=end|.
 
 = Options
+-h,--help	
+	print short help information and exit.
+-H,--Help	
+	print full documentation via less and exit.
+-V,--version	
+	print this script's version and exit.
+-l,--latex	
+	convert |``...''| to |“...”| before testing.
+-n,--number=N	
+	Set number of mismatching characters shown to N. By default, only the
+	first 10 are shown.
 -p,--pairs=S	
-	Set matching pairs to S (default: |{}[]()""“”''‘’|). For example, if you
-	want to look for mismatching ASCII single quotes /only/, use |--pairs="''"|.
+	Set matching pairs to S (default: |{}[]()""“”''‘’|). For
+	example, if you want to look for mismatching ASCII single quotes
+	/only/, use |--pairs="''"|.
 	Or, if you want to match braces and guillemets only, use |-p «»|.
 	Note that if html is detected in your text, |<>| is automatically added
 	to the pairs list. So by default, |<...>| is tested only in html, but
 	you can test that in other text by specifying the |<>| pair in the
 	|--pairs| option.
--n,--number=N	
-	Set number of mismatching characters shown to N. By default, only the
-	first 10 are shown.
--l,--latex	
-	convert |``...''| to |“...”|` before testing.
--V,--version	
-	print this script's version and exit.
--h,--help	
-	print short help information and exit.
    --test	
 	do an internal test and exit. Note that if, with the |--pairs| option,
 	you specify an other pairs list than the default, the test will
@@ -70,129 +75,172 @@
 
 = Examples
 Suppose we have two files, |good| and |bad|, containing these texts:
-	good:				bad:
-	This is a (simple) test 	This is a (simple test
-	without mismatches		containing mismatches
 
+good:	
+	This is a (simple) test
+	without mismatches
+
+bad:	
+	This is a (simple test
+	containing mismatches
+
 then here are some usage examples. First a simple test on these files:
-	$ match_parens good
-	      1 |	| This is a (simple) test
-	      2 |	| without mismatches
-	$ echo $?
-	0
-	$ match_parens bad
-	      1 | (	| This is a (simple test
-	      2 | (	| containing mismatches
-	$ echo $?
-	1
+   $ matchparens good
+         1 |	| This is a (simple) test
+         2 |	| without mismatches
+   $ echo $?
+   0
+   $ matchparens bad
+         1 | (	| This is a (simple test
+         2 | (	| containing mismatches
+   $ echo $?
+   1
 
 Just report if there are mismatches: 
-	$ match_parens good >/dev/null && echo fine || echo problems
-	fine
-	$ match_parens bad >/dev/null && echo fine || echo problems
-	problems
+   $ matchparens good >/dev/null && echo fine || echo problems
+   fine
+   $ matchparens bad >/dev/null && echo fine || echo problems
+   problems
 
 Report all tex files with mismatches in the current directory:
-	$ for i in *.tex; do match_parens $i >/dev/null || echo $i; done
+   $ for i in *.tex; do matchparens $i >/dev/null || echo $i; done
 
 Matches must be in correct order:
-	$ echo -e "This is a ([simple)] test\n" | match_parens
-	      1 ([)]	This is a ([simple)] test
-	      2 ([)]	
+   $ echo -e "This is a ([simple)] test\n" | match_parens
+         1 ([)]	This is a ([simple)] test
+         2 ([)]	
 
-= Changes
-Changes with respect to version 1.41:
-- test on more quote characters (single, double, ASCII, Unicode)
-- option for changing the character pairs to be tested
-- conversion of latex' ``...'' is now an option
-- built-in test option |--test|
+= Author
+[Wybo Dekker](wybo at dekkerdocumenten.nl)
 
-= Author and copyright
-Author	Wybo Dekker
-Email	U{Wybo at dekkerdocumenten.nl}{wybo at dekkerdocumenten.nl}
-License	Released under the U{www.gnu.org/copyleft/gpl.html}{GNU General Public License}
+= Copyright
+Released under the [GNU General Public License](www.gnu.org/copyleft/gpl.html)
 DOC
 
 require 'optparse'
+require 'ostruct'
 
-number, input, latex, lineno,  s,  html,  test,  parenstext =
-    10, STDIN, false,      0, '', false, false, %q{{}[]()""“”''‘’}
+def help
+  system("echo \"#{Help}\" | less -P#{Myname}-#{Version.tr('.','·')}")
+end
 
-ARGV.options do |opt|
-  opt.banner = "#{MYNAME} - find mismatches of parentheses, braces, (angle) brackets, in texts\n"
-  opt.on('-p','--pairs=S',String,
-    "set matching pairs to S (default: #{parenstext})"
-  ) do |v|
-      parenstext = v
-    end
-  opt.on('-n','--number=N',Integer,
-    "set number of mismatching characters shown to N (default: #{number})"
-  ) do |v|
-      number = v
-    end
-  opt.on('-l','--latex',
-    'convert ``...'' to “...” before testing') do
-      latex=true
-    end
-  opt.on('-V','--version',
-    'print version and exit') do
+# Option defaults:
+$o = OpenStruct.new(
+    :number => 10,
+     :input => STDIN,
+     :latex => false,
+    :lineno => 0,
+         :s => '',
+      :html => false,
+      :test => false,
+:parenstext => %q{{}[]()""“”''‘’}
+)
+
+OptionParser.new(
+   banner = <<~EOD,
+	#{Myname} A find mismatches of various brackets and quotes\n
+	Usage: match_parens [filename]\n
+	Options:
+	EOD
+   width = 15, # 2x8-1
+   indent = ''
+) do |opts|
+
+   opts.on('-h',
+      'print this help and exit'
+   ) do
+      puts opts.to_s.sub(/^ *-I\n/,'').gsub(/                 /,'')
+      exit
+   end
+
+   opts.on('-H','--help',
+      'print full documentation via less and exit'
+   ) do
+      help
+      exit
+   end
+
+   opts.on('-V','--version',
+      'print version and exit'
+   ) do
       puts Version
       exit
-    end
-  opt.on('-h','--help',
-    'print this help and exit') do
-      puts opt.to_s.sub(/^ *-I\n/,'')
+   end
+
+   opts.on('-l','--latex',
+     'convert ``...'' to “...” before testing'
+   ) do
+      $o.latex=true
+   end
+
+   opts.on('-n','--number=N',Integer,
+     "set number of mismatching characters shown to N (default: #{$o.number})"
+   ) do |v|
+      $o.number = v
+   end
+
+   opts.on('-p','--pairs=S',String,
+     "set matching pairs to S (default: #{$o.parenstext})"
+   ) do |v|
+      $o.parenstext = v
+   end
+
+   opts.on('--test',
+     'do an internal test and exit'
+   ) do
+      $o.input = DATA
+      $o.test = true
+   end
+
+   opts.on('-I') do
+      system("instscript #{Myname}")
       exit
-    end
-  opt.on('--test',
-    'do an internal test and exit') do
-      input = DATA
-      test = true
-    end
-  opt.on('-I') do system("instscript --zip --pdf --markdown #{MYNAME}"); exit; end
-  opt.parse!
+   end
+
+   opts.parse!
 end
-parenshtml = parenstext =~ /<>/ ? parenstext : parenstext + '<>'
-parens = parenstext
 
+parenshtml = $o.parenstext =~ /<>/ ? $o.parenstext : $o.parenstext + '<>'
+parens = $o.parenstext
+
 arg = ARGV[0] || ''
 unless arg.empty?
-  test(?e,arg) or raise("file #{arg} does not exist")
-  test(?r,arg) or raise("file #{arg} is not readable")
-  input = File.new(arg)
+   test(?e,arg) or raise("file #{arg} does not exist")
+   test(?r,arg) or raise("file #{arg} is not readable")
+   $o.input = File.new(arg)
 end
-while x = input.gets()
-  # convert LaTeX's ``...'' to “...”
-  if latex
-    x = x.gsub(/``/,'“').gsub(/''/,'”')
-  end
+while x = $o.input.gets()
+   # convert LaTeX's ``...'' to “...”
+   if $o.latex
+      x = x.gsub(/``/,'“').gsub(/''/,'”')
+   end
 
-  # only inside html text we check <>, too:
-  if html && (x=~/^([# ]*=end)/ || x=~/<\/html>/i)
-    html = false
-    parens = parenstext
-  elsif x=~/^([# ]*=begin rdoc)/ || x=~/<html>/i
-    html = true
-    parens = parenshtml
-  end
-  # match any pair like (), {}, [], “”, <> in parens
-  re = Regexp.new(parens.scan(/../).join('|').gsub(/[{}()\[\]]/,'\\\\\&'))
+   # only inside html text we check <>, too:
+   if $o.html && (x=~/^([# ]*=end)/ || x=~/<\/html>/i)
+      $o.html = false
+      parens = $o.parenstext
+   elsif x=~/^([# ]*=begin rdoc)/ || x=~/<html>/i
+      $o.html = true
+      parens = parenshtml
+   end
+   # match any pair like (), {}, [], “”, <> in parens
+   re = Regexp.new(parens.scan(/../).join('|').gsub(/[{}()\[\]$]/,'\\\\\&'))
 
-  # move parens' characters into s
-  s << x.tr('^'+parens,'')
-  # remove matches from inside
-  while s.gsub!(re,'') do end
-  puts "%4d | %-*s | %s" % [lineno+=1,number,s.slice(0..number-1),x]
+   # move parens' characters into s
+   $o.s << x.tr('^'+parens,'')
+   # remove matches from inside
+   while $o.s.gsub!(re,'') do end
+   puts "%4d | %-*s | %s" % [$o.lineno+=1,$o.number,$o.s.slice(0..$o.number-1),x]
 end
 
-if test
-  if s != '“{”}'
-    raise("test failed! (final mismatch should be “{”})")
-  else
-    puts "test succeeded"
-  end
+if $o.test
+   if s != '“{”}'
+      raise("test failed! (final mismatch should be “{”})")
+   else
+      puts "test succeeded"
+   end
 else
-  exit s.empty? ? 0 : 1
+   exit $o.s.empty? ? 0 : 1
 end
 __END__
 This first line “{()}” has no mismatch
@@ -199,7 +247,8 @@
 but here ( we have one.
 It is even extended “{() with two more.
 
-Here comes an untested angle bracket <, but here }” all) mismatches are erased.
+Here comes an untested angle bracket <, but here }” all) mismatches
+are erased.
 
 =begin rdoc
 Inside html text now. ‘{There is an unmatched} single quote here.

Added: trunk/Master/texmf-dist/doc/man/man1/match_parens.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/match_parens.1	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/man/man1/match_parens.1	2023-03-26 22:26:59 UTC (rev 66681)
@@ -0,0 +1,153 @@
+.TH match_parens 1 "March 23, 2023" "match_parens version 1.44" "DekDoc scripts"
+.SH NAME
+
+match_parens - find mismatches of various brackets and quotes
+
+.SH Synopsis
+
+.B match_parens [filename]
+
+.SS Options
+
+.B -h
+.RS
+print this help and exit
+.RE
+.B -H,--help
+.RS
+print full documentation and exit
+.RE
+.B -V,--version
+.RS
+print version and exit
+.RE
+.B -l,--latex
+.RS
+convert ``...'' to “...” before testing
+.RE
+.B -n,--number=N
+.RS
+set number of mismatching characters shown to N (default: 10)
+.RE
+.B -p,--pairs=S
+.RS
+set matching pairs to S (default: {}[]()""“”''‘’)
+.RE
+.B    --test
+.RS
+do an internal test and exit
+.RE
+
+.SH Description
+Mismatches of parentheses, braces, (angle) brackets, especially in TeX sources which may be rich in those, may be difficult to trace. This little script helps you by writing your text to standard output, after adding a left margin to your text, which will normally be almost empty, but will clearly show up to 10 mismatches. (Just try me on myself to see that the parenthesis starting this sentence will not appear to be matched at the end of the file. If you look at me in the vim editor, then select this paragraph and try the command: :!%. 
+
+By default, the following pairs are tested: 
+
+.B ()
+.RS
+round brackets or parentheses
+.RE
+.B {}
+.RS
+curly brackets or braces
+.RE
+.B []
+.RS
+square brackets
+.RE
+.B <>
+.RS
+angle brackets (within html text only)
+.RE
+.B ""
+.RS
+ASCII double quotes
+.RE
+.B “”
+.RS
+Unicode double quotation marks
+.RE
+.B ''
+.RS
+ASCII single quotes
+.RE
+.B ‘’
+.RS
+Unicode single quotation marks
+.RE
+
+The exit value of the script is 0 when there are no mismatches, 1 otherwise. 
+
+Angle brackets are only looked for inside HTML text, where HTML is supposed to start with <html> or =begin␣rdoc and to end with </html> or =end. 
+
+.SH Options
+
+.B -h,--help
+.RS
+print short help information and exit.
+.RE
+.B -H,--Help
+.RS
+print full documentation via less and exit.
+.RE
+.B -V,--version
+.RS
+print this script's version and exit.
+.RE
+.B -l,--latex
+.RS
+convert ``...'' to “...” before testing.
+.RE
+.B -n,--number=N
+.RS
+Set number of mismatching characters shown to N. By default, only the first 10 are shown.
+.RE
+.B -p,--pairs=S
+.RS
+Set matching pairs to S (default: {}[]()""“”''‘’). For example, if you want to look for mismatching ASCII single quotes \fIonly\fR, use --pairs="''". Or, if you want to match braces and guillemets only, use -p␣«». Note that if html is detected in your text, <> is automatically added to the pairs list. So by default, <...> is tested only in html, but you can test that in other text by specifying the <> pair in the --pairs option.
+.RE
+.B    --test
+.RS
+do an internal test and exit. Note that if, with the --pairs option, you specify an other pairs list than the default, the test will probably fail, but you can still see the effects of your pairs list on the test data.
+.RE
+
+.SH Examples
+Suppose we have two files, good and bad, containing these texts: 
+
+.B good:
+.RS
+This is a (simple) test without mismatches
+.RE
+
+.B bad:
+.RS
+This is a (simple test containing mismatches
+.RE
+
+then here are some usage examples. First a simple test on these files:    $ matchparens good
+         1 || This is a (simple) test
+         2 || without mismatches
+   $ echo $?
+   0
+   $ matchparens bad
+         1 | (| This is a (simple test
+         2 | (| containing mismatches
+   $ echo $?
+   1
+
+Just report if there are mismatches:     $ matchparens good >/dev/null && echo fine || echo problems
+   fine
+   $ matchparens bad >/dev/null && echo fine || echo problems
+   problems
+
+Report all tex files with mismatches in the current directory:    $ for i in *.tex; do matchparens $i >/dev/null || echo $i; done
+
+Matches must be in correct order:    $ echo -e "This is a ([simple)] test\n" | match_parens
+         1 ([)]This is a ([simple)] test
+         2 ([)]
+
+.SH Author
+Wybo Dekker (wybo at dekkerdocumenten.nl) 
+
+.SH Copyright
+Released under the GNU General Public License (www.gnu.org\fIcopyleft\fRgpl.html) 


Property changes on: trunk/Master/texmf-dist/doc/man/man1/match_parens.1
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/man/man1/match_parens.man1.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/man/man1/match_parens.man1.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/match_parens.man1.pdf	2023-03-26 20:40:32 UTC (rev 66680)
+++ trunk/Master/texmf-dist/doc/man/man1/match_parens.man1.pdf	2023-03-26 22:26:59 UTC (rev 66681)

Property changes on: trunk/Master/texmf-dist/doc/man/man1/match_parens.man1.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/doc/support/match_parens/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/match_parens/README	2023-03-26 20:40:32 UTC (rev 66680)
+++ trunk/Master/texmf-dist/doc/support/match_parens/README	2023-03-26 22:26:59 UTC (rev 66681)
@@ -1,25 +0,0 @@
-|
--------:|:--------------------------------------
- script:| match_parens - find mismatches of various brackets and quotes
-   type:| ruby
- author:| Wybo Dekker
-  email:| wybo at dekkerdocumenten.nl
-version:| 1.43
-license:| Released under the GNU General Public License
-
-Mismatches of parentheses, braces, (angle) brackets, especially in TeX
-sources which may be rich in those, may be difficult to trace. This little
-script helps you by writing your text to standard output, after adding a
-left margin to your text, which will normally be almost empty, but will
-clearly show up to 10 mismatches. (Just try me on myself to see that the
-parenthesis starting this sentence will not appear to be matched at the end
-of the file. If you look at me in the vim editor, then select this
-paragraph and try the command: :!%.
-
-Recent changes:
-Changes with respect to version 1.41:
-- test on more quote characters (single, double, ASCII, Unicode)
-- option for changing the character pairs to be tested
-- conversion of latex' ``...'' is now an option
-- built-in test option --test
-

Added: trunk/Master/texmf-dist/doc/support/match_parens/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/match_parens/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/match_parens/README.md	2023-03-26 22:26:59 UTC (rev 66681)
@@ -0,0 +1,15 @@
+ script: match_parens - find mismatches of various brackets and quotes
+   type: ruby
+ author: Wybo Dekker
+  email: wybo at dekkerdocumenten.nl
+version: 1.44
+license: GNU General Public License
+---
+Mismatches of parentheses, braces, (angle) brackets, especially in TeX
+sources which may be rich in those, may be difficult to trace. This little
+script helps you by writing your text to standard output, after adding a
+left margin to your text, which will normally be almost empty, but will
+clearly show up to 10 mismatches. (Just try me on myself to see that the
+parenthesis starting this sentence will not appear to be matched at the end
+of the file. If you look at me in the vim editor, then select this
+paragraph and try the command: :!%.


Property changes on: trunk/Master/texmf-dist/doc/support/match_parens/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/support/match_parens/match_parens.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/match_parens/match_parens
===================================================================
--- trunk/Master/texmf-dist/scripts/match_parens/match_parens	2023-03-26 20:40:32 UTC (rev 66680)
+++ trunk/Master/texmf-dist/scripts/match_parens/match_parens	2023-03-26 22:26:59 UTC (rev 66681)
@@ -1,9 +1,10 @@
 #!/usr/bin/env ruby
 # encoding: utf-8
 
- MYNAME = File.basename($0)
-Version = '1.43'
+ Myname = File.basename($0)
+Version = '1.44'
 
+Help=
 <<'DOC'
 = match_parens - find mismatches of various brackets and quotes
 
@@ -10,12 +11,13 @@
 = Synopsis
 match_parens [filename]	
 
-Options:
--p,--pairs=S	set matching pairs to S (default: |{}[]()""“”''‘’|)
+== Options
+-h		print this help and exit
+-H,--help	print full documentation and exit
+-V,--version	print version and exit
+-l,--latex	convert ``...'' to “...” before testing
 -n,--number=N	set number of mismatching characters shown to N (default: 10)
--l,--latex	convert |``...''| to |“...”| before testing
--V,--version	print version and exit
--h,--help	print short help information and exit
+-p,--pairs=S	set matching pairs to S (default: {}[]()""“”''‘’)
    --test	do an internal test and exit
 
 = Description
@@ -45,23 +47,26 @@
 |</html>| or |=end|.
 
 = Options
+-h,--help	
+	print short help information and exit.
+-H,--Help	
+	print full documentation via less and exit.
+-V,--version	
+	print this script's version and exit.
+-l,--latex	
+	convert |``...''| to |“...”| before testing.
+-n,--number=N	
+	Set number of mismatching characters shown to N. By default, only the
+	first 10 are shown.
 -p,--pairs=S	
-	Set matching pairs to S (default: |{}[]()""“”''‘’|). For example, if you
-	want to look for mismatching ASCII single quotes /only/, use |--pairs="''"|.
+	Set matching pairs to S (default: |{}[]()""“”''‘’|). For
+	example, if you want to look for mismatching ASCII single quotes
+	/only/, use |--pairs="''"|.
 	Or, if you want to match braces and guillemets only, use |-p «»|.
 	Note that if html is detected in your text, |<>| is automatically added
 	to the pairs list. So by default, |<...>| is tested only in html, but
 	you can test that in other text by specifying the |<>| pair in the
 	|--pairs| option.
--n,--number=N	
-	Set number of mismatching characters shown to N. By default, only the
-	first 10 are shown.
--l,--latex	
-	convert |``...''| to |“...”|` before testing.
--V,--version	
-	print this script's version and exit.
--h,--help	
-	print short help information and exit.
    --test	
 	do an internal test and exit. Note that if, with the |--pairs| option,
 	you specify an other pairs list than the default, the test will
@@ -70,129 +75,172 @@
 
 = Examples
 Suppose we have two files, |good| and |bad|, containing these texts:
-	good:				bad:
-	This is a (simple) test 	This is a (simple test
-	without mismatches		containing mismatches
 
+good:	
+	This is a (simple) test
+	without mismatches
+
+bad:	
+	This is a (simple test
+	containing mismatches
+
 then here are some usage examples. First a simple test on these files:
-	$ match_parens good
-	      1 |	| This is a (simple) test
-	      2 |	| without mismatches
-	$ echo $?
-	0
-	$ match_parens bad
-	      1 | (	| This is a (simple test
-	      2 | (	| containing mismatches
-	$ echo $?
-	1
+   $ matchparens good
+         1 |	| This is a (simple) test
+         2 |	| without mismatches
+   $ echo $?
+   0
+   $ matchparens bad
+         1 | (	| This is a (simple test
+         2 | (	| containing mismatches
+   $ echo $?
+   1
 
 Just report if there are mismatches: 
-	$ match_parens good >/dev/null && echo fine || echo problems
-	fine
-	$ match_parens bad >/dev/null && echo fine || echo problems
-	problems
+   $ matchparens good >/dev/null && echo fine || echo problems
+   fine
+   $ matchparens bad >/dev/null && echo fine || echo problems
+   problems
 
 Report all tex files with mismatches in the current directory:
-	$ for i in *.tex; do match_parens $i >/dev/null || echo $i; done
+   $ for i in *.tex; do matchparens $i >/dev/null || echo $i; done
 
 Matches must be in correct order:
-	$ echo -e "This is a ([simple)] test\n" | match_parens
-	      1 ([)]	This is a ([simple)] test
-	      2 ([)]	
+   $ echo -e "This is a ([simple)] test\n" | match_parens
+         1 ([)]	This is a ([simple)] test
+         2 ([)]	
 
-= Changes
-Changes with respect to version 1.41:
-- test on more quote characters (single, double, ASCII, Unicode)
-- option for changing the character pairs to be tested
-- conversion of latex' ``...'' is now an option
-- built-in test option |--test|
+= Author
+[Wybo Dekker](wybo at dekkerdocumenten.nl)
 
-= Author and copyright
-Author	Wybo Dekker
-Email	U{Wybo at dekkerdocumenten.nl}{wybo at dekkerdocumenten.nl}
-License	Released under the U{www.gnu.org/copyleft/gpl.html}{GNU General Public License}
+= Copyright
+Released under the [GNU General Public License](www.gnu.org/copyleft/gpl.html)
 DOC
 
 require 'optparse'
+require 'ostruct'
 
-number, input, latex, lineno,  s,  html,  test,  parenstext =
-    10, STDIN, false,      0, '', false, false, %q{{}[]()""“”''‘’}
+def help
+  system("echo \"#{Help}\" | less -P#{Myname}-#{Version.tr('.','·')}")
+end
 
-ARGV.options do |opt|
-  opt.banner = "#{MYNAME} - find mismatches of parentheses, braces, (angle) brackets, in texts\n"
-  opt.on('-p','--pairs=S',String,
-    "set matching pairs to S (default: #{parenstext})"
-  ) do |v|
-      parenstext = v
-    end
-  opt.on('-n','--number=N',Integer,
-    "set number of mismatching characters shown to N (default: #{number})"
-  ) do |v|
-      number = v
-    end
-  opt.on('-l','--latex',
-    'convert ``...'' to “...” before testing') do
-      latex=true
-    end
-  opt.on('-V','--version',
-    'print version and exit') do
+# Option defaults:
+$o = OpenStruct.new(
+    :number => 10,
+     :input => STDIN,
+     :latex => false,
+    :lineno => 0,
+         :s => '',
+      :html => false,
+      :test => false,
+:parenstext => %q{{}[]()""“”''‘’}
+)
+
+OptionParser.new(
+   banner = <<~EOD,
+	#{Myname} A find mismatches of various brackets and quotes\n
+	Usage: match_parens [filename]\n
+	Options:
+	EOD
+   width = 15, # 2x8-1
+   indent = ''
+) do |opts|
+
+   opts.on('-h',
+      'print this help and exit'
+   ) do
+      puts opts.to_s.sub(/^ *-I\n/,'').gsub(/                 /,'')
+      exit
+   end
+
+   opts.on('-H','--help',
+      'print full documentation via less and exit'
+   ) do
+      help
+      exit
+   end
+
+   opts.on('-V','--version',
+      'print version and exit'
+   ) do
       puts Version
       exit
-    end
-  opt.on('-h','--help',
-    'print this help and exit') do
-      puts opt.to_s.sub(/^ *-I\n/,'')
+   end
+
+   opts.on('-l','--latex',
+     'convert ``...'' to “...” before testing'
+   ) do
+      $o.latex=true
+   end
+
+   opts.on('-n','--number=N',Integer,
+     "set number of mismatching characters shown to N (default: #{$o.number})"
+   ) do |v|
+      $o.number = v
+   end
+
+   opts.on('-p','--pairs=S',String,
+     "set matching pairs to S (default: #{$o.parenstext})"
+   ) do |v|
+      $o.parenstext = v
+   end
+
+   opts.on('--test',
+     'do an internal test and exit'
+   ) do
+      $o.input = DATA
+      $o.test = true
+   end
+
+   opts.on('-I') do
+      system("instscript #{Myname}")
       exit
-    end
-  opt.on('--test',
-    'do an internal test and exit') do
-      input = DATA
-      test = true
-    end
-  opt.on('-I') do system("instscript --zip --pdf --markdown #{MYNAME}"); exit; end
-  opt.parse!
+   end
+
+   opts.parse!
 end
-parenshtml = parenstext =~ /<>/ ? parenstext : parenstext + '<>'
-parens = parenstext
 
+parenshtml = $o.parenstext =~ /<>/ ? $o.parenstext : $o.parenstext + '<>'
+parens = $o.parenstext
+
 arg = ARGV[0] || ''
 unless arg.empty?
-  test(?e,arg) or raise("file #{arg} does not exist")
-  test(?r,arg) or raise("file #{arg} is not readable")
-  input = File.new(arg)
+   test(?e,arg) or raise("file #{arg} does not exist")
+   test(?r,arg) or raise("file #{arg} is not readable")
+   $o.input = File.new(arg)
 end
-while x = input.gets()
-  # convert LaTeX's ``...'' to “...”
-  if latex
-    x = x.gsub(/``/,'“').gsub(/''/,'”')
-  end
+while x = $o.input.gets()
+   # convert LaTeX's ``...'' to “...”
+   if $o.latex
+      x = x.gsub(/``/,'“').gsub(/''/,'”')
+   end
 
-  # only inside html text we check <>, too:
-  if html && (x=~/^([# ]*=end)/ || x=~/<\/html>/i)
-    html = false
-    parens = parenstext
-  elsif x=~/^([# ]*=begin rdoc)/ || x=~/<html>/i
-    html = true
-    parens = parenshtml
-  end
-  # match any pair like (), {}, [], “”, <> in parens
-  re = Regexp.new(parens.scan(/../).join('|').gsub(/[{}()\[\]]/,'\\\\\&'))
+   # only inside html text we check <>, too:
+   if $o.html && (x=~/^([# ]*=end)/ || x=~/<\/html>/i)
+      $o.html = false
+      parens = $o.parenstext
+   elsif x=~/^([# ]*=begin rdoc)/ || x=~/<html>/i
+      $o.html = true
+      parens = parenshtml
+   end
+   # match any pair like (), {}, [], “”, <> in parens
+   re = Regexp.new(parens.scan(/../).join('|').gsub(/[{}()\[\]$]/,'\\\\\&'))
 
-  # move parens' characters into s
-  s << x.tr('^'+parens,'')
-  # remove matches from inside
-  while s.gsub!(re,'') do end
-  puts "%4d | %-*s | %s" % [lineno+=1,number,s.slice(0..number-1),x]
+   # move parens' characters into s
+   $o.s << x.tr('^'+parens,'')
+   # remove matches from inside
+   while $o.s.gsub!(re,'') do end
+   puts "%4d | %-*s | %s" % [$o.lineno+=1,$o.number,$o.s.slice(0..$o.number-1),x]
 end
 
-if test
-  if s != '“{”}'
-    raise("test failed! (final mismatch should be “{”})")
-  else
-    puts "test succeeded"
-  end
+if $o.test
+   if s != '“{”}'
+      raise("test failed! (final mismatch should be “{”})")
+   else
+      puts "test succeeded"
+   end
 else
-  exit s.empty? ? 0 : 1
+   exit $o.s.empty? ? 0 : 1
 end
 __END__
 This first line “{()}” has no mismatch
@@ -199,7 +247,8 @@
 but here ( we have one.
 It is even extended “{() with two more.
 
-Here comes an untested angle bracket <, but here }” all) mismatches are erased.
+Here comes an untested angle bracket <, but here }” all) mismatches
+are erased.
 
 =begin rdoc
 Inside html text now. ‘{There is an unmatched} single quote here.

Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2023-03-26 20:40:32 UTC (rev 66680)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2023-03-26 22:26:59 UTC (rev 66681)
@@ -1147,6 +1147,7 @@
     # look in the new dir we just created.
     $ctan_dir = $pkgdir;
   }
+  warn "ctan_dir: $ctan_dir\n";
 
   my @tl_files = ();
   push @tl_files, $tlp->runfiles;
@@ -1165,13 +1166,13 @@
     # the first one we come across, since we'll only find the first one
     # on CTAN and we don't want to try to match subdir suffixes.
     next if grep { $_ eq $basefile } @tl_basefiles;
-#warn "checking tl file $file -> $basefile\n";
+#warn "\nchecking tl file $file -> $basefile\n";
     push (@tl_basefiles, $basefile);
 
     # No point in comparing our pdfs now, too many are different.
     # However, for lshort translations and mathdesign, pdf can be
     # all we have to compare.
-    next if $file =~ /\.pdf$/ && $file !~ /short|mathdesign/;
+    next if $file =~ /\.pdf$/ && $file !~ /short|match_parens|mathdesign/;
     
     # seems mathpazo files were updated in TL and not CTAN.
     # Too old to worry about.
@@ -1199,13 +1200,13 @@
       next;
     }
     
-    chomp (@ctan_files = `find $ctan_dir/ -name $basefile`);
-#warn "ctan find $basefile: @ctan_files\n";
+    chomp (@ctan_files = `find $ctan_dir/ -name $basefile -type f`);
+#warn "  ctan find $basefile: @ctan_files\n";
     # the trailing / is so we dereference a symlink on CTAN.
     next if @ctan_files > 1; # if more than one file by same name, skip
 
     my $ctan_file = $ctan_files[0];
-#warn "ctan file is $ctan_file\n";
+#warn "  ctan file is $ctan_file\n";
     if (! -e $ctan_file) {
       # maybe it'll be there with a case change in the name
       chomp (@ctan_files = `find $ctan_dir/ -iname $basefile`);

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2023-03-26 20:40:32 UTC (rev 66680)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2023-03-26 22:26:59 UTC (rev 66681)
@@ -1738,6 +1738,7 @@
  'luaotfload'		=> '&POST_do_man',
  'luatexja'		=> '&POSTluatexja',
  'm-tx'			=> '&POSTmtx',
+ 'match_parens'		=> '&POST_do_man',
  'mathdesign'		=> '&POSTmathdesign',
  'mflogo'		=> '&POST_rmsymlink',
  'moderncv'		=> '&POST_deref_symlink',



More information about the tex-live-commits mailing list.