aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-01-17 05:33:42 +0100
committerPatrick Spek <p.spek@tyil.nl>2020-01-17 05:33:42 +0100
commit2fce26f303cd928ce6faf6c13d01ca8f6c283a97 (patch)
tree3b9de7657ae2a8c3ec497be8d2c3eff10710fbc2
parentad3758b22d5913837e19d97ab7cfd96d34ddcabb (diff)
downloadPod::To::HTML::Section-2fce26f303cd928ce6faf6c13d01ca8f6c283a97.tar.gz
Pod::To::HTML::Section-2fce26f303cd928ce6faf6c13d01ca8f6c283a97.tar.bz2
Workaround possible bug in pod6 rendering
Pod6 rendering classes appear to be invoked statically, making me unable to use instance state. This wouldn't be an issue per se, but it also appears that the pod document is rendered twice, but the first result being discarded. Seems like a bug to me, but perhaps its part of Pod::To::Anything? More research is needed.
-rw-r--r--lib/Pod/To/HTML/Section.pm623
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Pod/To/HTML/Section.pm6 b/lib/Pod/To/HTML/Section.pm6
index d47188c..e8dcfc4 100644
--- a/lib/Pod/To/HTML/Section.pm6
+++ b/lib/Pod/To/HTML/Section.pm6
@@ -8,10 +8,10 @@ use HTML::Escape;
unit class Pod::To::HTML::Section does Pod::To::Anything;
-my Int:D $no-para = 0;
+my $no-para;
my @authors;
-my $title = 'Unnamed module';
-my $version = '*';
+my $title;
+my $version;
my @notes;
multi method render (Pod::Block::Code:D $code --> Str) {
@@ -23,10 +23,7 @@ multi method render (Pod::Block::Declarator:D $declarator --> Str) {
}
multi method render (Pod::Block::Named::Author:D $author --> Str) {
- my $plain = self.unpod($author).&escape-html;
- if (@authors ∌ $plain) {
- @authors.append: $plain;
- }
+ @authors.append: self.unpod($author).&escape-html;
''
}
@@ -57,7 +54,18 @@ multi method render (Pod::Block::Named::Version:D $v --> Str) {
}
multi method render (Pod::Block::Named::Pod:D $document --> Str) {
+ # Reset all state, or counters will go wrong. It seems pod rendering classes
+ # are invoked statically, so I can't use standard object fields.
+ $no-para = 0;
+ @authors = ();
+ $title = 'Unnamed Module';
+ $version = '*';
+ @notes = ();
+
+ # Traverse the document, which will walk through all the elements.
my $body = self.traverse($document);
+
+ # Create the HTML section to output
my $section = qq:to/EOF/;
<section id="pod">
<h1>$title <small>{$version}</small></h1>
@@ -74,6 +82,7 @@ multi method render (Pod::Block::Named::Pod:D $document --> Str) {
}
}
+ # And output it.
$section ~ '</section>'
}