diff options
author | Akira Yokosawa <akiyks@gmail.com> | 2021-12-08 16:39:38 +0900 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2021-12-08 11:41:17 -0800 |
commit | 5697a32917f6f226d2c78bbae6300d929f86b9bd (patch) | |
tree | a153aa0785489961996478bd108efcce741aee6e /utilities | |
parent | f106e0e6dc436683bb119dd8992c6f173994d182 (diff) | |
download | perfbook-5697a32917f6f226d2c78bbae6300d929f86b9bd.tar.gz |
cleverefcheck.pl: Add test of listing next to heading
There is a side effect of fancyvrb, or the Verbatim{L|N|U}
environments derived from Verbatim, in that floating "listing"
environments placed just next to chapter/section headings are
treated as page/column-break candidates, and results in a widowed
heading.
Other floating objects such as "figure" and "table" do not
have this issue as long as they are free of fancyvrb.
Add tests to detect "listing" environments who come next to
\chapter/\section/\subsection/... commands.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/cleverefcheck.pl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/utilities/cleverefcheck.pl b/utilities/cleverefcheck.pl index 0085fdb5..f46cd89f 100755 --- a/utilities/cleverefcheck.pl +++ b/utilities/cleverefcheck.pl @@ -25,8 +25,11 @@ my $IX_ptn = qr/(^|\s+)IX[^\s\{]*{/ ; my $api_ptn = qr/(^|\s+)api[^\s\{]*{/ ; my $ppl_ptn = qr/(^|\s+)ppl[^\s\{]*{/ ; my $acr_ptn = qr/(^|\s+)[aA]cr[^\s\{]*{/ ; +my $heading_ptn = qr/(\\chapter|\\section|\\subsection|\\subsubsection)/ ; +my $listing_ptn = qr/\\begin\{(listing|Verbatim)/ ; my $in_footnote = 0 ; my $footnote_save = 0; +my $after_heading = 0; sub check_line { my $raw_line = $line; @@ -102,6 +105,18 @@ sub check_line { print $ARGV[0], ':', $line_num, ':', $raw_line; } } + if ($after_heading) { + if ($line =~ /^\s*$/) { + # ignore empty/blank line + } + if ($line =~ /^\s*\{*[A-Za-z0-9]/) { + $after_heading = 0 ; # normal line, OK + } + if ($line =~ /$listing_ptn/) { + print $ARGV[0], ':', $line_num, ':', $raw_line, "^^^ listing next to heading ^^^\n"; + $after_heading = 0 ; + } + } if ($line =~ /$Verbatim_end/) { $skip = 0; } else { @@ -135,6 +150,9 @@ sub check_line { } } } + if ($line =~ /$heading_ptn/) { + $after_heading = 1 ; + } } open(my $fh, '<:encoding(UTF-8)', $ARGV[0]) |