texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp/Texinfo/Convert HTML.pm


From: Patrice Dumas
Subject: texinfo/tp/Texinfo/Convert HTML.pm
Date: Sat, 30 Apr 2011 17:33:10 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/04/30 17:33:10

Modified files:
        tp/Texinfo/Convert: HTML.pm 

Log message:
        Handle preformatted.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.41&r2=1.42

Patches:
Index: HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- HTML.pm     30 Apr 2011 15:46:59 -0000      1.41
+++ HTML.pm     30 Apr 2011 17:33:09 -0000      1.42
@@ -717,12 +717,20 @@
          'span.roman'         => 'font-family:serif; font-weight:normal',
          'span.nocodebreak'   => 'white-space:pre',
          'span.nolinebreak'   => 'white-space:pre'
-     );
+);
 
 $css_map{'pre.format'} = $css_map{'pre.display'};
 $css_map{'pre.smallformat'} = $css_map{'pre.smalldisplay'};
 $css_map{'pre.smalllisp'} = $css_map{'pre.smallexample'};
 
+my %pre_class_commands;
+my %pre_class_types;
+foreach my $preformatted_command (keys(%preformatted_commands)) {
+  $pre_class_commands{$preformatted_command} = $preformatted_command;
+}
+$pre_class_commands{'menu'} = 'menu-preformatted';
+$pre_class_types{'menu_comment'} = 'menu-comment';
+
 foreach my $indented_format ('example', 'display', 'lisp')
 {
   $css_map{"div.$indented_format"} = 'margin-left: 3.2em';
@@ -1677,6 +1685,31 @@
 
 $default_types_conversion{'paragraph'} = \&_convert_paragraph_type;
 
+sub _convert_preformatted_type($$$$)
+{
+  my $self = shift;
+  my $type = shift;
+  my $command = shift;
+  my $content = shift;
+
+  my $current = $command;
+  my $pre_class;
+  return '' if ($content eq '');
+  while ($current->{'parent'}) {
+    $current = $current->{'parent'};
+    if ($current->{'cmdname'} and $pre_class_commands{$current->{'cmdname'}}) {
+      $pre_class = $pre_class_commands{$current->{'cmdname'}};
+      last;
+    } elsif ($current->{'type'} and $pre_class_types{$current->{'type'}}) {
+      $pre_class = $pre_class_types{$current->{'type'}};
+      last;
+    }
+  }
+  return $self->attribute_class('pre', $pre_class).">".$content."</pre>";
+}
+
+$default_types_conversion{'preformatted'} = \&_convert_preformatted_type;
+
 # FIXME this should be very rare since this is caught by _convert_text.
 sub _convert_empty_line_type($$$) {
   my $self = shift;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]