[PATCH -perfbook 2/4] cleverefcheck.pl: Add test of \begin{...} at head of QQA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux