OSDN Git Service

add new rule (begin-column,end-column,+---)
authorhylom <hylom@users.sourceforge.jp>
Mon, 2 Feb 2009 07:08:46 +0000 (16:08 +0900)
committerhylom <hylom@users.sourceforge.jp>
Mon, 2 Feb 2009 07:08:46 +0000 (16:08 +0900)
markup.pl

index cc40243..db9127d 100755 (executable)
--- a/markup.pl
+++ b/markup.pl
@@ -58,6 +58,14 @@ while( my $l = <> ) {
     ulist($l);
     next;
   }
+  elsif( $l =~ m/^☆begin-column:/ ) {
+    begin_column($l);
+    next;
+  }
+  elsif( $l =~ m/^☆end-column/ ) {
+    end_column($l);
+    next;
+  }
   elsif( $l =~ m/^☆space$/ ) {
     space($l);
     next;
@@ -77,6 +85,10 @@ while( my $l = <> ) {
     print $l, "\n";
     next;
   }
+  elsif( $l =~ m/^☆\+---$/ ) {
+      code($l);
+    next;
+  }
   elsif( $l =~ m/^☆表/ ) {
     table($l);
     next;
@@ -90,6 +102,7 @@ while( my $l = <> ) {
     next;
   }
 
+
   if( $l =~ m/^ / ) {
     $l = "<p>$l</p>";
   }
@@ -109,6 +122,37 @@ sub ulist {
     print "</ul>\n\n";
 }
 
+sub begin_column {
+    my $l = shift @_;
+
+    my $title = "";
+    if( $l =~ m/^☆begin-column:(.*)$/ ) {
+       $title = $1;
+    }
+    my $html = << "EOL";
+<table bgcolor="#DDDDDD" border="0" cellpadding="6" width="95%">
+<tr>
+<th>$title</th>
+</tr>
+<tr>
+<td>
+<span style="font-size: 85%;;">
+EOL
+
+    print $html;
+}
+
+sub end_column {
+    my $l = shift @_;
+    my $html = << "EOL";
+</span>
+</td>
+</tr>
+</table>
+EOL
+    print $html;
+}
+
 sub list {
     my $l = shift @_;
     my $cap = "";
@@ -133,6 +177,25 @@ sub list {
     print list_end();
 }
 
+sub code {
+    my $l = shift @_;
+    my $cap = "";
+
+    print list_start();
+    while( $l = <> ) {
+      chomp $l;
+      $l =~ s/&/&amp;/g;
+      $l =~ s/</&lt;/g;
+      $l =~ s/>/&gt;/g;
+
+      if( $l =~ m/^[+-]---$/ ) {
+       last;
+      }
+      print $l, "\n";
+    }
+    print list_end();
+}
+
 sub list_start {
   return "<pre>\n";
 }