match_parens: new tool to check parenthesis matching
The script match_parens has been uploaded to CTAN today. This program has been written by Wybo Dekker to assist the user in checking parenthesis (and braces, brackets) balancing in documents, the characters {}[]()<> are supported.
It’s written in Ruby, though it’s been announced on ctan-ann as Perl script, therefore a Ruby installation is required. On Ubuntu (and Debian) Linux systems Ruby can be installed by:
sudo apt-get install ruby
which installs libruby1.8, ruby, ruby1.8 on Ubuntu 9.04. Of course it could be done using Synaptic on Ubuntu as well. You can define the script to be executable by
chmod u+x match_parens
or use option a instead of u to allow execution by all users. Afterwards the script could by invoked with the name of the file to be checked as parameter, like
./match_parens test.tex
The output of the programm will show mismatches at the left margin. Have a look at this example:
1 [ [Hello, here is some 2 text] (without) a meaning. 3 ( (This text should show, 4 ( how a printed text will 5 look like at this place.) 6 ({ ({If you read this text, 7 you will get no information}). 8 Really? Is there no information? 9 [ Is there [a difference between 10 this text and ] some nonsense 11 like Huardest gefburn . Kjift – 12 (( Never mind! (A blind text (like 13 ( this) gives you information about 14 ({[ {[the selected font, how the 15 ({[ letters are written and the 16 ({[) impression of the look). 17 ({[) |
Unmached parentheses can be seen on the left, vanishing after being matched, at the end you can see the remaining matching problems.
This small tool with its just about 20 lines of Ruby code can be useful especially in checking large TeX documents where errors for instance caused by nested braces could be hard to locate.
This text is available in German. Dieser Text ist auch in Deutsch verfügbar.