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 2/4] cleverefcheck.pl: Add test of \begin{...} at head of QQA
Date: Wed, 8 Dec 2021 16:41:26 +0900	[thread overview]
Message-ID: <bff4b6a9-c8fd-e026-75f6-16f422ca652b@gmail.com> (raw)
In-Reply-To: <4350078f-4054-cb28-157b-305d6df087ea@gmail.com>

QQA's heading of "Answer:" looks similar to a section heading,
but it behaves differently when there is some environment next
to it.
Also, if there is an empty line at the head of QQA, "Answer:" can
be widowed.

Add tests to detect such potential break patterns in QQA.

Note: \begin{fcvref} is an exception.  It doesn't induce
page/column break.

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

diff --git a/utilities/cleverefcheck.pl b/utilities/cleverefcheck.pl
index f46cd89f..74ac9d72 100755
--- a/utilities/cleverefcheck.pl
+++ b/utilities/cleverefcheck.pl
@@ -27,9 +27,11 @@ 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 $qqa_ptn = qr/\\E?QuickQuizAnswer[BEM]?/ ;
 my $in_footnote = 0 ;
 my $footnote_save = 0;
 my $after_heading = 0;
+my $after_qqa = 0;
 
 sub check_line {
     my $raw_line = $line;
@@ -117,6 +119,18 @@ sub check_line {
 	    $after_heading = 0 ;
 	}
     }
+    if ($after_qqa) {
+	if ($line =~ /^\s*$/) {
+	    print $ARGV[0], ':', $line_num, ':', $raw_line, "~~~ Empty line at QQA head ^^^\n" ;
+	}
+	if ($line =~ /^\s*\\begin/ && $line !~ /fcvref/) {
+	    print $ARGV[0], ':', $line_num, ':', $raw_line, "^^^ environment next to QQA ~~~\n";
+	    $after_qqa = 0 ;
+	}
+	if ($line =~ /^\s*\{*[^\\]+/) {
+	    $after_qqa = 0;
+	}
+    }
     if ($line =~ /$Verbatim_end/) {
 	$skip = 0;
     } else {
@@ -153,6 +167,9 @@ sub check_line {
     if ($line =~ /$heading_ptn/) {
 	$after_heading = 1 ;
     }
+    if ($line =~ /$qqa_ptn/) {
+	$after_qqa = 1 ;
+    }
 }
 
 open(my $fh, '<:encoding(UTF-8)', $ARGV[0])
-- 
2.17.1



  parent reply	other threads:[~2021-12-08  7:41 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 ` Akira Yokosawa [this message]
2021-12-08  7:49 ` [PATCH -perfbook 3/4] cleverefcheck.pl: Add test of \begin{...} next to epigraph Akira Yokosawa
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=bff4b6a9-c8fd-e026-75f6-16f422ca652b@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.