mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-21 19:39:44 +01:00
applets/cstd.pl: Fix footnotes
This commit is contained in:
parent
6a61de1026
commit
4551318c56
32
applets/cstd.pl
vendored
32
applets/cstd.pl
vendored
@ -15,6 +15,9 @@ my %standards = (
|
||||
C23 => 'n3047.out',
|
||||
);
|
||||
|
||||
binmode(STDOUT, ":utf8");
|
||||
binmode(STDERR, ":utf8");
|
||||
|
||||
@ARGV = map { decode('UTF-8', $_, 1) } @ARGV;
|
||||
|
||||
my ($std, $search, $section, $paragraph, $debug);
|
||||
@ -133,20 +136,20 @@ my $qsearch = quotemeta $search;
|
||||
$qsearch =~ s/\\ / /g;
|
||||
$qsearch =~ s/\s+/\\s+/g;
|
||||
|
||||
while ($text =~ m/^([0-9A-Z]+\.[0-9.]*)/msg) {
|
||||
while ($text =~ m/^([0-9A-Z]+\.[0-9.]*)/msgi) {
|
||||
$this_section = $1;
|
||||
|
||||
print "----------------------------------\n" if $debug >= 2;
|
||||
print "Processing section [$this_section]\n" if $debug;
|
||||
|
||||
if ($section_specified and $this_section !~ m/^$section/i) {
|
||||
if ($section_specified and $this_section !~ m/^\Q$section/i) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
my $section_text;
|
||||
|
||||
if ($text =~ m/(.*?)^(?=\s{0,4}(?!Footnote)[0-9A-Z]+\.)/msg) {
|
||||
if ($text =~ /(.*?)^(?=\s{0,4}(?!Footnote)[0-9A-Z]+\.)/msg) {
|
||||
$section_text = $1;
|
||||
} else {
|
||||
print "No section text, end of file marker found.\n" if $debug >= 4;
|
||||
@ -157,6 +160,7 @@ while ($text =~ m/^([0-9A-Z]+\.[0-9.]*)/msg) {
|
||||
$section_text =~ s/^\s{4}//ms;
|
||||
$section_text =~ s/^\s{4}Footnote.*//msi;
|
||||
$section_text =~ s/^\d.*//ms;
|
||||
$section_text = $this_section . $section_text;
|
||||
} elsif ($section_text =~ m/(.*?)$/msg) {
|
||||
$section_title = $1 if length $1;
|
||||
$section_title =~ s/^\s+//;
|
||||
@ -247,28 +251,17 @@ if (not $found and $comma eq "") {
|
||||
exit 1;
|
||||
}
|
||||
|
||||
$result =~ s/$found_section_title// if length $found_section_title;
|
||||
$result =~ s/\Q$found_section_title// if length $found_section_title;
|
||||
$result =~ s/^\s+//;
|
||||
$result =~ s/\s+$//;
|
||||
|
||||
=cut
|
||||
$result =~ s/\s+/ /g;
|
||||
$result =~ s/[\n\r]/ /g;
|
||||
=cut
|
||||
|
||||
if ($matches > 1 and not $list_only) { print "Displaying $match of $matches matches: "; }
|
||||
|
||||
if ($comma eq "") {
|
||||
|
||||
=cut
|
||||
print $found_section;
|
||||
print "p" . $found_paragraph if $paragraph_specified;
|
||||
=cut
|
||||
|
||||
print "http://www.iso-9899.info/$std_name.html\#$found_section";
|
||||
print "p" . $found_paragraph if $paragraph_specified;
|
||||
print "\n\n";
|
||||
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
||||
print "http://www.iso-9899.info/$std_name.html\#$found_section";
|
||||
print "p" . $found_paragraph if $paragraph_specified;
|
||||
print "\n\n";
|
||||
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
||||
}
|
||||
|
||||
$result =~ s/\s*Constraints\s*$//;
|
||||
@ -277,6 +270,7 @@ $result =~ s/\s*Description\s*$//;
|
||||
$result =~ s/\s*Returns\s*$//;
|
||||
$result =~ s/\s*Runtime-constraints\s*$//;
|
||||
$result =~ s/\s*Recommended practice\s*$//;
|
||||
$result =~ s/Footnote\.(\d)/Footnote $1/g;
|
||||
|
||||
if (length $match_text) {
|
||||
my $match_result = $result;
|
||||
|
6
applets/gencstd.pl
vendored
6
applets/gencstd.pl
vendored
@ -23,7 +23,7 @@ binmode(STDERR, ":utf8");
|
||||
my $input = "@ARGV";
|
||||
|
||||
if (not length $input) {
|
||||
print STDERR "Usage: $0 <input .txt file>\n";
|
||||
print STDERR "Usage: $0 <input file>\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ sub gen_txt {
|
||||
foreach my $this_section (sort bysection keys %sections) {
|
||||
print STDERR "writing section $this_section\n" if $debug;
|
||||
if (not $this_section =~ m/p/) {
|
||||
print " $this_section $sections{$this_section}{title}\n";
|
||||
print "$this_section $sections{$this_section}{title}\n";
|
||||
$section_head = $this_section;
|
||||
$section_title = $sections{$this_section}{title};
|
||||
}
|
||||
@ -297,7 +297,7 @@ sub gen_txt {
|
||||
if ($paren == -1) {
|
||||
if (length $number and defined $footnotes[$number]) {
|
||||
print STDERR "Got footnote $number here!\n" if $debug;
|
||||
$footer .= "\nFOOTNOTE.$number) $footnotes[$number]\n";
|
||||
$footer .= "\nFootnote.$number) $footnotes[$number]\n";
|
||||
}
|
||||
|
||||
$paren = 0;
|
||||
|
678
applets/n1256.out
vendored
678
applets/n1256.out
vendored
File diff suppressed because it is too large
Load Diff
938
applets/n1570.out
vendored
938
applets/n1570.out
vendored
File diff suppressed because it is too large
Load Diff
1117
applets/n3047.out
vendored
1117
applets/n3047.out
vendored
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4571,
|
||||
BUILD_REVISION => 4572,
|
||||
BUILD_DATE => "2022-08-12",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user