match_parens(1)
π NAME π
okay so bestie, meet match_parens β the DekDoc scripts darling known as match_parens(1), and its whole job is: find mismatches of various brackets and quotes. literally that's it, and it ate. π
π Synopsis π
match_parens [filename]
β¨ 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)-p,--pairs=Sβ set matching pairs to S (default:{}[]()ββ«»ββ""'')--testβ do an internal test and exit
π¦ 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:
()β round brackets or parentheses{}β curly brackets or braces[]β square brackets<>β angle brackets (within html text only)""β ASCII double quotesβββ Unicode double quotation marks''β ASCII single quotesβββ Unicode single quotation marks
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.
π Options π
okay bestie, here's the full menu β yes, some of it repeats the synopsis, and no, we do not skip it. π
-h,--helpβ print short help information and exit.-H,--Helpβ print full documentation vialessand 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="''". 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--pairsoption.--testβ do an internal test and exit. Note that if, with the--pairsoption, 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.
π Examples π
Suppose we have two files, good and bad, containing these texts:
good:This is a (simple) test without mismatchesbad:This is a (simple test containing mismatches
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)] test0 | match_parens
1 ([)]This is a ([simple)] test
2 ([)]
π«Ά Author π«Ά
Wybo Dekker (wybodekker@me.com) β iconic.
π Copyright π
Released under the GNU General Public License (www.gnu.orgcopyleftgpl.html).
π that's the whole manual, bestie: match_parens version 1.45, dated September 30, 2025 β go match those brackets and quotes, and remember: no cap, only correct order. π
β¨
π¦ where this page comes from
- alpine 3.24: texmf-dist-binextra-doc 2026.0-r0 Β· LPPL-1.0 AND LPPL-1.1 AND LPPL-1.2 AND LPPL-1.3a AND LPPL-1.3c AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms