SYN SYN
[p5sagit/p5-mst-13.2.git] / lib / Pod / Html.pm
index 00b7e89..f70a42b 100644 (file)
@@ -893,6 +893,10 @@ sub scan_dir {
            $pages{$_}  = "" unless defined $pages{$_};
            $pages{$_} .= "$dir/$_.pod:";
            push(@pods, "$dir/$_.pod");
+       } elsif (/\.html\z/) {                              # .html
+           s/\.html\z//;
+           $pages{$_}  = "" unless defined $pages{$_};
+           $pages{$_} .= "$dir/$_.pod:";
        } elsif (/\.pm\z/) {                                # .pm
            s/\.pm\z//;
            $pages{$_}  = "" unless defined $pages{$_};
@@ -1351,17 +1355,19 @@ sub process_puretext {
        # skip space runs
        next if $word =~ /^\s*$/;
        # see if we can infer a link
-       if( $notinIS && $word =~ /^(\w+)\((.*)\)\W*$/ ) {
+       if( $notinIS && $word =~ /^(\w+)\((.*)\)$/ ) {
            # has parenthesis so should have been a C<> ref
             ## try for a pagename (perlXXX(1))?
-            if( $2 =~ /^\d+$/ ){
+            my( $func, $args ) = ( $1, $2 );
+            if( $args =~ /^\d+$/ ){
                 my $url = page_sect( $word, '' );
                 if( defined $url ){
                     $word = "<A HREF=\"$url\">the $word manpage</A>";
                     next;
                 }
             }
-           $word = emit_C( $word );
+            ## try function name for a link, append tt'ed argument list
+            $word = emit_C( $func, '', "($args)");
 
 #### disabled. either all (including $\W, $\w+{.*} etc.) or nothing.
 ##      } elsif( $notinIS && $word =~ /^[\$\@%&*]+\w+$/) {
@@ -1410,10 +1416,13 @@ sub process_text {
 
 sub process_text1($$;$$){
     my( $lev, $rstr, $func, $closing ) = @_;
-    $lev++ unless defined $func;
     my $res = '';
 
-    $func ||= '';
+    unless (defined $func) {
+       $func = '';
+       $lev++;
+    }
+
     if( $func eq 'B' ){
        # B<text> - boldface
        $res = '<STRONG>' . process_text1( $lev, $rstr ) . '</STRONG>';
@@ -1433,8 +1442,10 @@ sub process_text1($$;$$){
 
     } elsif( $func eq 'E' ){
        # E<x> - convert to character
-       $$rstr =~ s/^(\w+)>//;
-       $res = "&$1;";
+       $$rstr =~ s/^([^>]*)>//;
+       my $escape = $1;
+       $escape =~ s/^(\d+|X[\dA-F]+)$/#$1/i;
+       $res = "&$escape;";
 
     } elsif( $func eq 'F' ){
        # F<filename> - italizice
@@ -1584,8 +1595,7 @@ sub process_text1($$;$$){
            return $res if !$3 && $lev > 1;
             if( $3 ){
                $res .= process_text1( $lev, $rstr, $3, closing $4 );
-           }
-
+           }
        }
        if( $lev == 1 ){
            $res .= pure_text( $$rstr );
@@ -1622,13 +1632,14 @@ sub go_ahead($$$){
 # emit_C - output result of C<text>
 #    $text is the depod-ed text
 #
-sub emit_C($;$){
-    my( $text, $nocode ) = @_;
+sub emit_C($;$$){
+    my( $text, $nocode, $args ) = @_;
+    $args = '' unless defined $args;
     my $res;
     my( $url, $fid ) = coderef( undef(), $text );
 
     # need HTML-safe text
-    my $linktext = html_escape( $text );
+    my $linktext = html_escape( "$text$args" );
 
     if( defined( $url ) &&
         (!defined( $EmittedItem ) || $EmittedItem ne $fid ) ){
@@ -1930,12 +1941,12 @@ sub depod1($;$$){
       # skip to next begin of an interior sequence
       while( $$rstr =~ s/\A(.*?)([BCEFILSXZ])<(<+[^\S\n]+)?// ){
          # recurse into its text
-         $res .= $1 . depod1( $rstr, $2, closing $3);
+         $res .= $1 . depod1( $rstr, $2, closing $3);
       }
       $res .= $$rstr;
   } elsif( $func eq 'E' ){
       # E<x> - convert to character
-      $$rstr =~ s/^(\w+)>//;
+      $$rstr =~ s/^([^>]*)>//;
       $res .= $E2c{$1} || "";
   } elsif( $func eq 'X' ){
       # X<> - ignore
@@ -1946,7 +1957,7 @@ sub depod1($;$$){
   } else {
       # all others: either recurse into new function or
       # terminate at closing angle bracket
-      my $term = pattern $closing; 
+      my $term = pattern $closing;
       while( $$rstr =~ s/\A(.*?)(([BCEFILSXZ])<(<+[^\S\n]+)?|$term)// ){
          $res .= $1;
          last unless $3;