--- lib/Padre/Plugin/PDL/Help.pm	2012-03-14 10:08:38.000000000 -0500
+++ ../Padre-Plugin-PDL-0.04/lib/Padre/Plugin/PDL/Help.pm	2012-03-14 11:54:52.000000000 -0500
@@ -31,15 +31,8 @@
 		}
 
 		if ( defined $pdldoc ) {
+			# Store in self for later access:
 			$self->{pdl_help} = $pdldoc;
-
-			# Delete those cool PDL modules that
-			# Perl 5 Help search will include
-			for my $k ( keys %{ $self->{pdl_help} } ) {
-				if ( $k =~ /^PDL::/ ) {
-					delete $self->{pdl_help}->{$k};
-				}
-			}
 		}
 	};
 	if ($@) {
@@ -61,34 +54,31 @@
 
 	my ( $html, $location );
 	my $pdl_help = $self->{pdl_help};
-	if ( defined $pdl_help && exists $pdl_help->{$topic} ) {
-		$html = '';
-		my $help         = $pdl_help->{$topic};
-		my %SECTION_NAME = (
-			Module  => 'Module',
-			Ref     => 'Reference',
-			Sig     => 'Signature',
-			Bad     => 'Bad values',
-			Usage   => 'Usage',
-			Example => 'Example',
-		);
-		foreach my $section (qw(Module Ref Sig Bad Usage Example)) {
-			if ( defined $help->{$section} ) {
-				my $help = $help->{$section};
-				my $name = $SECTION_NAME{$section};
-				if (   $section eq 'Example'
-					or $section eq 'Sig'
-					or $section eq 'Usage' )
-				{
-					$html .= "<p><b>$name</b><pre>" . $help . "</pre></p>";
-				} elsif ( $section eq 'Module' ) {
-					$html .= qq{<p><b><a href="perldoc:$help">$help</a></b></p>};
-				} else {
-					$html .= "<p><b>$name</b><br>" . $help . "</p>";
-				}
-			}
+	if ( defined $pdl_help && exists $pdl_help->gethash->{$topic} ) {
+		require Padre::Pod2HTML;
+		
+		# We have two possibilities: the $topic can either be a module, or it
+		# can be a function. If the latter, we extract its pod from the database.
+		# If the former, just pull the pod from the file. We distinguish between
+		# them by noting that functions have a Module key, whereas modules 
+		# (ironically) don't.
+		if (exists $pdl_help->gethash->{$topic}->{Module}) {
+			# Get the pod docs from the docs database:
+			my $pod_handler = StrHandle->new; # defined in PDL::Doc
+			$pdl_help->funcdocs($topic, $pod_handler);
+			
+			# Convert them to HTML
+			$html = Padre::Pod2HTML->pod2html($pod_handler->text);
+			
+			# Replace the filename in the "docs from" section with the module name:
+			my $module_name = $pdl_help->gethash->{$topic}{Module};
+			$html =~ s{Docs from .*\.pm}
+				{Docs from <a href="perldoc:$module_name">$module_name<\/a>};
 		}
-
+		else {
+			$html = Padre::Pod2HTML->file2html($pdl_help->gethash->{$topic}->{File});
+		}
+		
 		$location = $topic;
 	} else {
 		( $html, $location ) = $self->{p5_help}->help_render($topic);
@@ -107,10 +97,13 @@
 	my @index = keys %{ $self->{pdl_help}->gethash };
 
 	# Add Perl 5 help index to PDL
-	foreach my $topic ( @{ $self->{p5_help}->help_list } ) {
-		push @index, $topic;
-	}
+	#foreach my $topic ( @{ $self->{p5_help}->help_list } ) {
+	#	push @index, $topic;
+	#}
+	# I think this is a faster way of doing the above:
+	push @index, @{ $self->{p5_help}->help_list };
 
+	# Make sure things are only listed once:
 	my %seen = ();
 	my @unique_sorted_index = sort grep { !$seen{$_}++ } @index;
 	return \@unique_sorted_index;
