Commits

Toby Inkster committed 2f21ffa

preserve =for pod tags

Comments (0)

Files changed (1)

lib/TOBYINK/Pod/HTML.pm

 		$self->perldoc_url_prefix("https://metacpan.org/module/");
 		return $self;
 	}
+	
+	sub get_token
+	{
+		my $self = shift;
+		my $tok = $self->SUPER::get_token;
+		
+		if (defined $tok and $tok->[0] eq 'start' and $tok->[1] eq 'for')
+		{
+			my $target = $tok->[2]{"target"};
+			my $data;
+			until ($tok->[0] eq 'end' and $tok->[1] eq 'for')
+			{
+				$data .= $tok->[1] if $tok->[0] eq 'text';
+				$tok = $self->SUPER::get_token;
+			}
+			print {$self->{"output_fh"}} "<!-- for $target $data -->\n";
+			$tok = $self->SUPER::get_token;
+		}
+		
+		return $tok;
+	}
 }
 
 {
 		
 		my $tmp;
 		my $p = "TOBYINK::Pod::HTML::Helper"->new;
+		$p->accept_targets(__PACKAGE__);
 		$p->output_string(\$tmp);
 		$p->$method($input);
 		return $tmp;
 		%{ $dom->querySelector('head meta') } = (charset => 'utf-8');
 		
 		# No useful comments
-		$_->parentNode->removeChild($_) for $dom->findnodes('//comment()');
+		$_->parentNode->removeChild($_) for grep { not /for TOBYINK::Pod::HTML/ } $dom->findnodes('//comment()');
 		
 		# Drop these <a name> elements
 		$dom->querySelectorAll('a[name]')->foreach(sub
 
 =head1 SYNOPSIS
 
+=for TOBYINK::Pod::HTML highlighting=perl
+
    #!/usr/bin/perl
    
    use strict;