summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-02-13 23:58:45 +0000
committerKarl Berry <karl@freefriends.org>2015-02-13 23:58:45 +0000
commit798876c6f2e5e0bce28929bb6fc2a1c3497df469 (patch)
tree49f9fe2d1186a298e06719b149c0319d3f8bcc15 /Master/texmf-dist/scripts
parentadb258e2566a62dd146e173f09516dce4f8b7b1e (diff)
match_parens (13feb15)
git-svn-id: svn://tug.org/texlive/trunk@36270 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/match_parens/match_parens25
1 files changed, 13 insertions, 12 deletions
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=~/<html>/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