All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: perfbook@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH -perfbook 3/4] cleverefcheck.pl: Add test of \begin{...} next to epigraph
Date: Wed, 8 Dec 2021 16:49:10 +0900	[thread overview]
Message-ID: <4f7654f2-738a-2986-2cb1-fc0177cec135@gmail.com> (raw)
In-Reply-To: <4350078f-4054-cb28-157b-305d6df087ea@gmail.com>

If a section heading has an epigraph next to it and an
environment of some sort follows the epigraph, the behavior
of a proper LaTeX heading is lost.

Add tests to detect such potential break patterns following
epigraphs.

Notes:
  o "Any environment" does not include "fcvref".
  o "listing" is caught by other tests for it.
  o glossary.tex has "description" list next to its epigraph.
    As it is at the head of an appendix and won't cause
    page/colum break, it is ignored.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 utilities/cleverefcheck.pl | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/utilities/cleverefcheck.pl b/utilities/cleverefcheck.pl
index 74ac9d72..6e9a59e8 100755
--- a/utilities/cleverefcheck.pl
+++ b/utilities/cleverefcheck.pl
@@ -28,10 +28,12 @@ my $acr_ptn = qr/(^|\s+)[aA]cr[^\s\{]*{/ ;
 my $heading_ptn = qr/(\\chapter|\\section|\\subsection|\\subsubsection)/ ;
 my $listing_ptn = qr/\\begin\{(listing|Verbatim)/ ;
 my $qqa_ptn = qr/\\E?QuickQuizAnswer[BEM]?/ ;
+my $epig_ptn = qr/\\[Ee]pigraph/ ;
 my $in_footnote = 0 ;
 my $footnote_save = 0;
 my $after_heading = 0;
 my $after_qqa = 0;
+my $after_epig = 0;
 
 sub check_line {
     my $raw_line = $line;
@@ -117,6 +119,7 @@ sub check_line {
 	if ($line =~ /$listing_ptn/) {
 	    print $ARGV[0], ':', $line_num, ':', $raw_line, "^^^ listing next to heading ^^^\n";
 	    $after_heading = 0 ;
+	    $after_epig = 0 ;  # after epigraph or not does not matter for listing
 	}
     }
     if ($after_qqa) {
@@ -131,6 +134,15 @@ sub check_line {
 	    $after_qqa = 0;
 	}
     }
+    if ($after_epig) {
+	if ($line =~ /^\s*$/) {  # empty line ends epigraph
+	    $after_epig -= 1 ;
+	}
+	if ($line =~ /^\s*\\begin/ && $line !~ /(fcvref|listing)/) {
+	    print $ARGV[0], ':', $line_num, ':', $raw_line, "^^^ environment next to epigraph ^^^\n";
+	    $after_epig = 0 ;
+	}
+    }
     if ($line =~ /$Verbatim_end/) {
 	$skip = 0;
     } else {
@@ -170,6 +182,9 @@ sub check_line {
     if ($line =~ /$qqa_ptn/) {
 	$after_qqa = 1 ;
     }
+    if ($line =~ /$epig_ptn/ && $ARGV[0] !~ /glossary\.tex/) { # exempt glossary.tex
+	$after_epig = 2 ;
+    }
 }
 
 open(my $fh, '<:encoding(UTF-8)', $ARGV[0])
-- 
2.17.1



  parent reply	other threads:[~2021-12-08  7:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08  7:37 [PATCH -perfbook 0/4] Address potential widowing of headings Akira Yokosawa
2021-12-08  7:39 ` [PATCH -perfbook 1/4] cleverefcheck.pl: Add test of listing next to heading Akira Yokosawa
2021-12-08  7:41 ` [PATCH -perfbook 2/4] cleverefcheck.pl: Add test of \begin{...} at head of QQA Akira Yokosawa
2021-12-08  7:49 ` Akira Yokosawa [this message]
2021-12-08  7:52 ` [PATCH -perfbook 4/4] treewide: Address potential widowing of headings Akira Yokosawa
2021-12-08 19:55 ` [PATCH -perfbook 0/4] " Paul E. McKenney
2021-12-08 22:20   ` Akira Yokosawa
2021-12-08 23:58     ` Paul E. McKenney
2021-12-09  0:03       ` Akira Yokosawa
2021-12-09  6:28         ` Zhouyi Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f7654f2-738a-2986-2cb1-fc0177cec135@gmail.com \
    --to=akiyks@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=perfbook@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.