Debian Codegraph @

texmf-dist/doc/man/man1/match_parens.1

raw
1 .TH match_parens 1 "September 30, 2025" "match_parens version 1.45" "DekDoc scripts"
2 .SH NAME
3
4 match_parens - find mismatches of various brackets and quotes
5
6 .SH Synopsis
7
8 .B match_parens [filename]
9
10 .SS Options
11
12 .B -h
13 .RS
14 print this help and exit
15 .RE
16 .B -H,--help
17 .RS
18 print full documentation and exit
19 .RE
20 .B -V,--version
21 .RS
22 print version and exit
23 .RE
24 .B -l,--latex
25 .RS
26 convert ``...'' to “...” before testing
27 .RE
28 .B -n,--number=N
29 .RS
30 set number of mismatching characters shown to N (default: 10)
31 .RE
32 .B -p,--pairs=S
33 .RS
34 set matching pairs to S (default: {}[]()“”«»‘’""'')
35 .RE
36 .B --test
37 .RS
38 do an internal test and exit
39 .RE
40
41 .SH Description
42 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: :!%.
43
44 By default, the following pairs are tested:
45
46 .B ()
47 .RS
48 round brackets or parentheses
49 .RE
50 .B {}
51 .RS
52 curly brackets or braces
53 .RE
54 .B []
55 .RS
56 square brackets
57 .RE
58 .B <>
59 .RS
60 angle brackets (within html text only)
61 .RE
62 .B ""
63 .RS
64 ASCII double quotes
65 .RE
66 .B “”
67 .RS
68 Unicode double quotation marks
69 .RE
70 .B ''
71 .RS
72 ASCII single quotes
73 .RE
74 .B ‘’
75 .RS
76 Unicode single quotation marks
77 .RE
78
79 The exit value of the script is 0 when there are no mismatches, 1 otherwise.
80
81 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.
82
83 .SH Options
84
85 .B -h,--help
86 .RS
87 print short help information and exit.
88 .RE
89 .B -H,--Help
90 .RS
91 print full documentation via less and exit.
92 .RE
93 .B -V,--version
94 .RS
95 print this script's version and exit.
96 .RE
97 .B -l,--latex
98 .RS
99 convert ``...'' to “...” before testing.
100 .RE
101 .B -n,--number=N
102 .RS
103 Set number of mismatching characters shown to N. By default, only the first 10 are shown.
104 .RE
105 .B -p,--pairs=S
106 .RS
107 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.
108 .RE
109 .B --test
110 .RS
111 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.
112 .RE
113
114 .SH Examples
115 Suppose we have two files, good and bad, containing these texts:
116
117 .B good:
118 .RS
119 This is a (simple) test without mismatches
120 .RE
121
122 .B bad:
123 .RS
124 This is a (simple test containing mismatches
125 .RE
126
127 then here are some usage examples. First a simple test on these files: $ matchparens good
128 1 || This is a (simple) test
129 2 || without mismatches
130 $ echo $?
131 0
132 $ matchparens bad
133 1 | (| This is a (simple test
134 2 | (| containing mismatches
135 $ echo $?
136 1
137
138 Just report if there are mismatches: $ matchparens good >/dev/null && echo fine || echo problems
139 fine
140 $ matchparens bad >/dev/null && echo fine || echo problems
141 problems
142
143 Report all tex files with mismatches in the current directory: $ for i in *.tex; do matchparens $i >/dev/null || echo $i; done
144
145 Matches must be in correct order: $ echo -e "This is a ([simple)] test\n" | match_parens
146 1 ([)]This is a ([simple)] test
147 2 ([)]
148
149 .SH Author
150 Wybo Dekker ([email protected])
151
152 .SH Copyright
153 Released under the GNU General Public License (www.gnu.org\fIcopyleft\fRgpl.html)