Skip to content

Commit c3d8e69

Browse files
committedDec 18, 2020
.nf blocks may be ended with .SH
1 parent 4281af7 commit c3d8e69

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed
 

‎man-to-md.pl

+7-4
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ sub postprocess_synopsis {
382382

383383
sub reformat_syntax {
384384
# commands to be ignored:
385-
if (m/^\.(?:PD|hy|ad|\s|$)/) {
385+
if (m/^\.(?:PD|hy|ad|ft|fi|\s|$)/) {
386386
$_ = '';
387387
return
388388
}
@@ -703,13 +703,16 @@ sub read_version {
703703
nextline() if (section_title && $is_synopsis);
704704

705705

706-
do {
706+
do {{
707+
PARSELINE:
708+
707709
if ($in_rawblock) {
708-
if (m/^\.(?:fi|cx)/) {
710+
if (m/^\.(?:fi|SH|cx)/) {
709711
# code block ends
710712
$in_rawblock = 0;
711713
print "</code></pre>\n" if $code_formatting;
712714
print "\n" if m/^\.cx/;
715+
redo if m/^\.SH/; # .nf sections can be ended with .SH, but we still need to print the new section title too
713716
} elsif ($code_formatting) {
714717
# inside code block with limited html formatting
715718
if ($in_rawblock == 2) {
@@ -768,7 +771,7 @@ sub read_version {
768771
print
769772
}
770773

771-
} while (nextline(1));
774+
}} while (nextline(1));
772775

773776

774777
# Paste section which haven't matched anything yet:

‎test/90-test-bug-nf-sh.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
. $(dirname "$0")/init.sh
3+
4+
# .nf code blocks may be ended with a new section title (.SH).
5+
6+
output="$(conv code.roff)"
7+
8+
expectedFragment=
9+
expectedFragment="${expectedFragment}^# Unterminated\b.*"
10+
expectedFragment="${expectedFragment}^ +my\b.*"
11+
expectedFragment="${expectedFragment}^ +code\b.*"
12+
expectedFragment="${expectedFragment}^# Terminator*"
13+
14+
assertRegex "$output" "/$expectedFragment/ms"
15+
16+
17+
success

‎test/samples/code.roff

+6
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ cm-output1
3434
cm-output2 \\" not a comment
3535
.cx
3636
text 1
37+
.SH UNTERMINATED
38+
.nf
39+
my
40+
code
41+
.SH TERMINATOR
42+
ttt

0 commit comments

Comments
 (0)
Please sign in to comment.