From 798876c6f2e5e0bce28929bb6fc2a1c3497df469 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 13 Feb 2015 23:58:45 +0000 Subject: match_parens (13feb15) git-svn-id: svn://tug.org/texlive/trunk@36270 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/support/match_parens/README | 2 +- .../doc/support/match_parens/match_parens.pdf | Bin 56974 -> 57068 bytes .../texmf-dist/scripts/match_parens/match_parens | 25 +++++++++++---------- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/support/match_parens/README b/Master/texmf-dist/doc/support/match_parens/README index 0f85ac80296..115d88f9533 100644 --- a/Master/texmf-dist/doc/support/match_parens/README +++ b/Master/texmf-dist/doc/support/match_parens/README @@ -4,7 +4,7 @@ type:| ruby author:| Wybo Dekker email:| wybo@dekkerdocumenten.nl -version:| 1.42 +version:| 1.43 license:| Released under the GNU General Public License Mismatches of parentheses, braces, (angle) brackets, especially in TeX diff --git a/Master/texmf-dist/doc/support/match_parens/match_parens.pdf b/Master/texmf-dist/doc/support/match_parens/match_parens.pdf index e137ea6d46b..59f9f99b156 100644 Binary files a/Master/texmf-dist/doc/support/match_parens/match_parens.pdf and b/Master/texmf-dist/doc/support/match_parens/match_parens.pdf differ diff --git a/Master/texmf-dist/scripts/match_parens/match_parens b/Master/texmf-dist/scripts/match_parens/match_parens index e6f74663902..5387e908d9d 100755 --- a/Master/texmf-dist/scripts/match_parens/match_parens +++ b/Master/texmf-dist/scripts/match_parens/match_parens @@ -2,7 +2,7 @@ # encoding: utf-8 MYNAME = File.basename($0) -Version = '1.42' +Version = '1.43' <<'DOC' = match_parens - find mismatches of various brackets and quotes @@ -115,8 +115,8 @@ DOC require 'optparse' -number, input, latex, n, s, html, test, parenstext = - 10, STDIN, false, 10, '', false, false, %q{{}[]()""“”''‘’} +number, input, latex, lineno, s, html, test, parenstext = + 10, STDIN, false, 0, '', false, false, %q{{}[]()""“”''‘’} ARGV.options do |opt| opt.banner = "#{MYNAME} - find mismatches of parentheses, braces, (angle) brackets, in texts\n" @@ -132,8 +132,7 @@ ARGV.options do |opt| end opt.on('-l','--latex', 'convert ``...'' to “...” before testing') do - puts opt.to_s.sub(/^ *-I\n/,'') - exit + latex=true end opt.on('-V','--version', 'print version and exit') do @@ -164,24 +163,26 @@ unless arg.empty? end while x = input.gets() # convert LaTeX's ``...'' to “...” - x = x.gsub(/``/,'“').gsub(/''/,'”') + if latex + x = x.gsub(/``/,'“').gsub(/''/,'”') + end # only inside html text we check <>, too: if html && (x=~/^([# ]*=end)/ || x=~/<\/html>/i) - html = false - parens = parenstext + html = false + parens = parenstext elsif x=~/^([# ]*=begin rdoc)/ || x=~//i - html = true - parens = parenshtml + html = true + parens = parenshtml end # match any pair like (), {}, [], “”, <> in parens re = Regexp.new(parens.scan(/../).join('|').gsub(/[{}()\[\]]/,'\\\\\&')) - # remove {x} where x in []{}()<>, copy all parens to s + # move parens' characters into s s << x.tr('^'+parens,'') # remove matches from inside while s.gsub!(re,'') do end - puts "%4d | %-*s | %s" % [n+=1,number,s.slice(0..number-1),x] + puts "%4d | %-*s | %s" % [lineno+=1,number,s.slice(0..number-1),x] end if test -- cgit v1.2.3