OSDN Git Service

章の中を{{section}}で区切れるようにした。
authortakezoe <takezoe@871d6764-1e22-0410-b313-a55050885396>
Wed, 23 Nov 2011 00:44:11 +0000 (00:44 +0000)
committertakezoe <takezoe@871d6764-1e22-0410-b313-a55050885396>
Wed, 23 Nov 2011 00:44:11 +0000 (00:44 +0000)
takezoe/plugin/book/Install.pm
takezoe/plugin/book/Section.pm [new file with mode: 0644]
takezoe/plugin/book/TocParser.pm

index fd02863..8fda54a 100644 (file)
@@ -10,6 +10,7 @@ use plugin::book::TocParser;
 sub install {
        my $wiki  = shift;
        $wiki->add_paragraph_plugin("chapter", "plugin::book::Chapter", "HTML");
+       $wiki->add_paragraph_plugin("section", "plugin::book::Section", "HTML");
        $wiki->add_inline_plugin("title1", "plugin::book::Title1", "HTML");
        $wiki->add_inline_plugin("title2", "plugin::book::Title2", "HTML");
        $wiki->add_inline_plugin("title3", "plugin::book::Title3", "HTML");
diff --git a/takezoe/plugin/book/Section.pm b/takezoe/plugin/book/Section.pm
new file mode 100644 (file)
index 0000000..763c9f6
--- /dev/null
@@ -0,0 +1,34 @@
+################################################################################
+#
+# <p>¾Ï¤Î¸«½Ð¤·¤ò½ÐÎϤ¹¤ë¥Ñ¥é¥°¥é¥Õ¥×¥é¥°¥¤¥ó¡£</p>
+# <pre>
+# {{chapter 1,¤Ï¤¸¤á¤Ë}}
+# </pre>
+# <p>
+#   Â¾¤Î¥×¥é¥°¥¤¥ó¤Ç¤Ï¤³¤Î¥×¥é¥°¥¤¥ó¤ÇÄêµÁ¤·¤¿¾ÏÈÖ¹æ¤ò»È¤Ã¤Æ¿ÞɽÈÖ¹æ¤Ê¤É¤ò¿¶¤Ã¤Æ
+#   ¤¤¤ë¤¿¤á¡¢1¥Ú¡¼¥¸¤ËºÇÄã1¤Ä¤Ï¤³¤Î¥×¥é¥°¥¤¥ó¤òµ­½Ò¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£
+# </p>
+#
+################################################################################
+package plugin::book::Section;
+#==============================================================================
+# ¥³¥ó¥¹¥È¥é¥¯¥¿
+#==============================================================================
+sub new {
+       my $class = shift;
+       my $self = {};
+       return bless $self,$class;
+}
+
+#==============================================================================
+# ¥Ñ¥é¥°¥é¥Õ¥á¥½¥Ã¥É
+#==============================================================================
+sub paragraph {
+       my $self  = shift;
+       my $wiki  = shift;
+       my $title = shift;
+       
+       return ''
+}
+
+1;
index 7a62ac8..0f611b6 100644 (file)
@@ -28,7 +28,9 @@ sub new {
        $self->{'outline_html'}  = "";
        $self->{'outline_level'} =  0;
        $self->{'outline_cnt'}   =  0;
+       $self->{'outline_fix'}   =  0;
        $self->{'pagename'}      = $page;
+       $self->{'section_cnt'}   =  0;
        return bless $self,$class;
 }
 
@@ -40,6 +42,8 @@ sub l_headline {
        my $level = shift;
        my $obj   = shift;
        
+       $level = $level + $self->{'outline_fix'};
+       
        if($level > $self->{'display_level'}){
                $self->{outline_cnt}++;
                return;
@@ -73,8 +77,12 @@ sub l_headline {
        }
        
        $self->{'outline_close_'.$level} = 1;
-       $self->{outline_html} .= "<li><a href=\"?page=".Util::url_encode($self->{pagename})."#p".$self->{outline_cnt}."\">$text</a>";
-       $self->{outline_cnt}++;
+       if($self->{'outline_fix'} == 1 && $level == 1){
+               $self->{outline_html} .= "<li>$text";
+       } else {
+               $self->{outline_html} .= "<li><a href=\"?page=".Util::url_encode($self->{pagename})."#p".$self->{outline_cnt}."\">$text</a>";
+               $self->{outline_cnt}++;
+       }
 }
 
 #==============================================================================
@@ -133,6 +141,15 @@ sub l_plugin{
                $self->{'chapter'} = $plugin->{'args'}->[0];
                return undef;
        }
+       if($plugin->{'command'} eq 'section'){
+               if($self->{'outline_fix'} == 0){
+                       $self->{'outline_fix'} = 1;
+                       $self->{'display_level'}++;
+               }
+               $self->{'section_cnt'}++;
+               $self->l_headline(0, [$plugin->{'args'}->[0]]);
+               return undef;
+       }
        
        # outline°Ê³°¤Î¾ì¹ç¤Î¤ß½èÍý¤ò¹Ô¤¦
        if($plugin->{command} ne "outline"){