/[pub]/suikawiki/script/misc/plugins/SuikaWiki09.wp2
Suika

Diff of /suikawiki/script/misc/plugins/SuikaWiki09.wp2

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by wakaba, Sat Dec 13 04:53:59 2003 UTC revision 1.10 by wakaba, Sat Mar 20 03:21:19 2004 UTC
# Line 5  Plugin: Line 5  Plugin:
5    @Description:    @Description:
6      @@@: SuikaWiki/0.9 document format      @@@: SuikaWiki/0.9 document format
7      @@lang:en      @@lang:en
8    @License: %%GPL%%    @License: %%Perl%%
9    @Author:    @Author:
10      @@Name:      @@Name:
11        @@@@: Wakaba        @@@@: Wakaba
12        @@@lang:ja        @@@lang:ja
13        @@@script:Latn        @@@script:Latn
14      @@Mail[list]: [email protected]      @@Mail[list]: [email protected]
15    @Date.RCS: $Date$    @Date.RCS:
16        $Date$
17    @RequiredPlugin[list]:    @RequiredPlugin[list]:
18        Edit
19        WikiFormCore
20      WikiLinking      WikiLinking
21        WikiStruct
22    @Use:    @Use:
23      use Message::Markup::XML::QName qw/NS_xml_URI/;      use Message::Markup::XML::QName qw/NS_xml_URI/;
24      my $Reg_Form_Content_M = qr{      my $Reg_Form_Content_M = qr{
# Line 23  Plugin: Line 27  Plugin:
27   \               \( (\w+) \)                                 ## id   \               \( (\w+) \)                                 ## id
28   \             )?   \             )?
29   \             : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) '       ## input   \             : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) '       ## input
30   \         (?: : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) '       ## template   \         (?> : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) '       ## template
31   \         (?: : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' )? )? ## option   \         (?> : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' )? )? ## option
32      }x;      }x;
33      my $Reg_Embed_Content_M = qr{      my $Reg_Embed_Content_M = qr{
34   \     \#([a-z-]+)   \     \#([a-z-]+)
# Line 45  Plugin: Line 49  Plugin:
49   \     )   \     )
50      }x;      }x;
51    
52        my ($WIKIRESOURCE, $WIKISTRUCT, $WIKIFORMCORE, $WIKILINKING);
53    
54  PluginConst:  PluginConst:
55    @NS_SW09:    @NS_SW09:
56      urn:x-suika-fam-cx:markup:suikawiki:0:9:      urn:x-suika-fam-cx:markup:suikawiki:0:9:
# Line 54  PluginConst: Line 60  PluginConst:
60      http://www.w3.org/1999/xhtml      http://www.w3.org/1999/xhtml
61    @NS_XHTML2:    @NS_XHTML2:
62      http://www.w3.org/2002/06/xhtml2      http://www.w3.org/2002/06/xhtml2
63      @WIKIFORMCORE:
64        {($WIKIFORMCORE ||= SuikaWiki::Plugin->module_package ('WikiFormCore'))}
65      @WIKILINKING:
66        {($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))}
67      @WIKIRESOURCE:
68        {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
69      @WIKISTRUCT:
70        {($WIKISTRUCT ||= SuikaWiki::Plugin->module_package ('WikiStruct'))}
71    
72    
73    
74  Format:  Format:
75    @ModuleName:    @ModuleName:
# Line 80  Format: Line 96  Format:
96        
97    @Use:    @Use:
98      use Message::Markup::XML::QName qw/NS_xml_URI/;      use Message::Markup::XML::QName qw/NS_xml_URI/;
99        use Message::Util::Error;
100    
101    @Converter:    @Converter:
102      @@Type: text/html      @@Type: text/html
# Line 88  Format: Line 105  Format:
105        @@@@: Converting SuikaWiki/0.9 to Hypertext Markup Language fragment        @@@@: Converting SuikaWiki/0.9 to Hypertext Markup Language fragment
106        @@@lang:en        @@@lang:en
107      @@Main:      @@Main:
108  #      __FUNCPACK__->to_html ($source, %$opt);        $opt->{o}->{wiki} ||= $self->{wiki};
109          
110      ## Text format -> XML format      ## Text format -> XML format
111        my $xml = new Message::Markup::XML::Node type => '#fragment';        my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => $opt,
112        __FUNCPACK__->text_to_xml ($source, {%$opt, -parent => $xml});                                              wiki => $self->{wiki});
113    
114        ## SuikaWiki/0.9 -> XHTML 1
115          __FUNCPACK__->sw09_to_xhtml1 (source => $xml, parent => $opt->{-parent},
116                                        o => $opt->{o}, page => $opt->{page});
117    
118          if ($opt->{-with_annotation_input}) {
119            SuikaWiki::Plugin->module_package ('WikiFormCore')
120                             ->make_content_form_in_html
121                                 ($opt->{-parent},
122                                  $WIKIRESOURCE->get
123                                    (name => 'SuikaWiki/0.9:form:footannotate:input',
124                                     o => $opt->{o}, wiki => $opt->{o}->{wiki}),
125                                  option => $WIKIRESOURCE->get
126                                    (name => 'SuikaWiki/0.9:form:footannotate:option',
127                                     o => $opt->{o}, wiki => $opt->{o}->{wiki}),
128                                  o => $opt->{o},
129                                  wiki => $opt->{o}->{wiki},
130                                  output => {
131                                    page => $opt->{page},
132                                  });
133          }
134    
135    
136      @Converter:
137        @@Type:
138          @@@@: application/x-suikawiki+xml
139          @@@version: 0.9
140        @@Description:
141          @@@@: Converting SuikaWiki/0.9 text format to XML format
142          @@@lang: en
143        @@Main:
144          my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => $opt,
145                                                wiki => $self->{wiki});
146    ## TODO: Make a clone
147          $opt->{-parent}->append_node ($xml);
148    
149      @NextIndex:
150        @@Name: anchor
151        @@Main:
152          my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => \%opt,
153                                                wiki => $self->{wiki});
154          (__FUNCPACK__->get_last_anchor_index ($xml)) + 1;
155      
156      @WikiForm:
157        @@Main:
158          ## Text format -> XML format
159          my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => \%opt,
160                                                wiki => $self->{wiki});
161          local $opt{o}->{var}->{sw09__anchor_index};
162          local $opt{o}->{var}->{sw09__document_tree} = $xml;
163    
164          my $form;
165          if ($opt{o}->{form}->{output}->{id}) {
166            $form = __FUNCPACK__->get_element_by_id
167                      ($xml, $opt{o}->{form}->{output}->{id});
168            undef $form unless ref $form and
169                               $form->namespace_uri eq $NS_SW09 and
170                               $form->local_name eq 'form';
171          } else {
172            $form = __FUNCPACK__->get_nth_element
173                      ($xml, $NS_SW09 => 'form',
174                       $opt{o}->{form}->{output}->{index});
175          }
176          
177          my $ref;
178          if (ref $form) {
179            $ref = $form->get_attribute_value ('ref', default => 'form');
180          } else {
181            $ref = '#footannotate';
182          }
183          
184          
185          ## WikiForm Option
186          if ($ref eq 'form') {
187            $opt{option} ||= $form->get_attribute_value ('option');
188          } elsif ($ref eq 'comment') {
189            $opt{option} ||= $WIKIRESOURCE->get
190                               (name => 'SuikaWiki/0.9:form:comment:option',
191                                o => $opt{o}, wiki => $opt{o}->{wiki});
192          } elsif ($ref eq '#footannotate') {
193            $opt{option} ||= $WIKIRESOURCE->get
194                               (name => 'SuikaWiki/0.9:form:footannotate:option',
195                                o => $opt{o}, wiki => $opt{o}->{wiki});
196          } else {
197    ## TODO:
198          }
199          SuikaWiki::Plugin->module_package ('WikiFormCore')
200                           ->set_option ($opt{option} => $opt{o}) if $opt{option};
201                
202          ## Replace Output Template
203          my $result;
204          if ($ref eq 'form') {
205            $opt{template} ||= $form->get_attribute_value
206                                        ('template', default => '');
207          } elsif ($ref eq 'comment') {
208            $opt{template} ||= $WIKIRESOURCE->get
209                                 (name => 'SuikaWiki/0.9:form:comment:template',
210                                  o => $opt{o}, wiki => $opt{o}->{wiki});
211          } elsif ($ref eq '#footannotate') {
212            $opt{template} ||= $WIKIRESOURCE->get
213                                 (name => 'SuikaWiki/0.9:form:footannotate:template',
214                                  o => $opt{o}, wiki => $opt{o}->{wiki});
215          }
216          try {
217            $result = SuikaWiki::Plugin->text_formatter ('form_template')
218                             ->replace ($opt{template}, param => $opt{o});
219          } catch Message::Util::Formatter::error with {
220            my $err = shift;
221            SuikaWiki::Plugin->module_package ('Error')
222                             ->reporting_formatting_template_error
223                                 ($err, $err->{option}->{param}->{wiki});
224    ##TODO:
225            throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
226          };      
227    
228          ## Insert
229          if (length $result) {
230            if ($ref eq '#footannotate') {
231              my $parent;
232              for (@{$xml->child_nodes}) {
233                if ($_->node_type eq '#element' and
234                    $_->local_name eq 'document') {
235                  for (@{$_->child_nodes}) {
236                    if ($_->node_type eq '#element' and
237                        $_->local_name eq 'body') {
238                      $parent = $_;
239                      last;
240                    }
241                  }
242                }
243              }
244              CORE::die "Buggy implementation: no body element".$xml
245                        unless ref $parent;
246              
247              $parent->append_new_node (type => '#element',
248                                        namespace_uri => $NS_SW09,
249                                        local_name => 'text')
250                     ->append_text ($result);
251            } else {
252              my $parent = $form->parent_node;
253              CORE::die "Byggy implementation: No parent of form" unless ref $parent;
254              my $children = $parent->child_nodes;
255              
256              $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
257              $parent->append_new_node (type => '#element',
258                                        namespace_uri => $NS_SW09,
259                                        local_name => 'text')
260                     ->append_text ($result);
261              my $node = pop @{$children};
262              my $form_str = overload::StrVal ($form);
263              my $i = 0;
264              for (@{$children}) {
265                last if overload::StrVal ($_) eq $form_str;
266                $i++;
267              }
268              if ($opt{o}->{form}->{output}->{reverse}) {
269                splice @{$children}, $i + 1, 0, $node;
270              } else {
271                splice @{$children}, $i, 0, $node;
272              }
273            }
274          } else {
275    ## TODO:
276          }
277    
278          ## XML format -> Text format
279          my $text = __FUNCPACK__->xml_to_text ($xml, {%opt});
280    
281          my %fragment = (fragment => $opt{o}->{form}->{output}->{id}
282                                || 'wikiform-'.$opt{o}->{form}->{output}->{index});
283          if (not $opt{o}->{form}->{output}->{reverse} and
284              $opt{o}->{var}->{sw09__anchor_index}) {
285            %fragment = (anchor_no => $opt{o}->{var}->{sw09__anchor_index});
286          }
287    
288          my $action = [
289            {
290              type => 'write',
291              content => $text,
292              update_lastmodified => time,
293            },
294            {
295              type => 'view',
296              %fragment,
297            },
298          ];
299    
300      @HeadSummary:
301        @@Main:
302          my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => \%opt,
303                                                wiki => $self->{wiki});
304          return $xml->inner_text;
305    
306    FormattingRule:
307      @Category[list]:form-template
308      @Name: index
309      @Description:
310        @@@: Next anchor index number
311        @@lang:en
312      @After:
313        if ($o->{var}->{sw09__anchor_index}) {
314          ++$o->{var}->{sw09__anchor_index};
315        } else {
316          $o->{var}->{sw09__anchor_index}
317            = 1 + __FUNCPACK__->get_last_anchor_index
318                                  ($o->{var}->{sw09__document_tree});
319        }
320        $p->{-result} .= $o->{var}->{sw09__anchor_index};
321    
322    Function:
323      @Name: get_last_anchor_index
324      @Main:
325          my (undef, $xml) = @_;
326          my $anchor = 0;
327          my $get_anchor_no;
328          $get_anchor_no = sub {
329            my $node = shift;
330            for my $child (@{$node->child_nodes}) {
331              my $nt = $child->node_type;
332              if ($nt eq '#element') {
333                if ($child->namespace_uri => $NS_SW09 and
334                    $child->local_name eq 'anchor-end') {
335                  my $a = $child->get_attribute_value ('anchor', default => 0,
336                                                       namespace_uri => $NS_SW09);
337                  $anchor = 0+$a if $anchor < 0+$a;
338                } else {
339                  $get_anchor_no->($child);
340                }
341              } elsif ($nt eq '#document' or $nt eq '#fragment') {
342                $get_anchor_no->($child);
343              }
344            }
345          };
346          $get_anchor_no->($xml);
347          $anchor;
348    
349    
350    Function:
351      @Name: get_xml_tree
352      @Main:
353        my (undef, %opt) = @_;
354        if ($opt{opt}->{page}) {
355      ## TODO:
356          unless ($__FUNCPACK__::DBLoaded) {
357            $opt{wiki}->{db}->_set_prop_db (sw09__xml_tree => {-db_open => sub {
358              require SuikaWiki::DB::Hash;
359              new SuikaWiki::DB::Hash;
360            }});
361            $__FUNCPACK__::DBLoaded++;
362          }
363        
364          my $xml = new Message::Markup::XML::Node type => '#fragment';
365          __FUNCPACK__->text_to_xml (${$opt{text}}, {%{$opt{opt}}, -parent => $xml});
366    
367          $opt{wiki}->{db}->set (sw09__xml_tree => $opt{opt}->{page} => $xml);
368          $xml;
369        } else {
370          my $xml = new Message::Markup::XML::Node type => '#fragment';
371          __FUNCPACK__->text_to_xml (${$opt{text}}, {%{$opt{opt}}, -parent => $xml});
372          $xml;
373        }
374    
375    Function:
376      @Name: sw09_to_xhtml1
377      @Main:
378        my (undef, %opt) = @_;
379    
380        my ($apply_template, $apply_template_children);        my ($apply_template, $apply_template_children);
381        $apply_template_children = sub {        $apply_template_children = sub {
382          my ($parent, $result) = @_;          for (@{$_[0]->child_nodes}) {
383          for (@{$parent->child_nodes}) {            $apply_template->($_ => $_[1]) unless $_->node_type eq '#attribute';
           $apply_template->($_ => $result) unless $_->node_type eq '#attribute';  
384          }          }
385        };        };
386        $apply_template = sub {        $apply_template = sub {
# Line 113  Format: Line 396  Format:
396            my $class = $source->get_attribute_value ('class', default => '');            my $class = $source->get_attribute_value ('class', default => '');
397            $node->set_attribute (class => $class) if $class;            $node->set_attribute (class => $class) if $class;
398            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
399          } elsif ({qw/ins 1 del 1/}->{$ln}) {          } elsif ({qw/ins 1 del 1 insert 1 delete 1/}->{$ln}) {
400            my $node = $result->append_new_node            my $node = $result->append_new_node
401                                  (type => '#element',                                  (type => '#element',
402                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
403                                   local_name => $ln);                                   local_name => {qw/ins ins insert ins
404                                                       delete del del del/}->{$ln});
405            my $class = $source->get_attribute_value ('class', default => '');            my $class = $source->get_attribute_value ('class', default => '');
406            $node->set_attribute (class => $class) if $class;            $node->set_attribute (class => $class) if $class;
407            ## TODO: cite            ## TODO: cite
# Line 134  Format: Line 418  Format:
418            } elsif ($ln eq 'pre') {            } elsif ($ln eq 'pre') {
419              $node->set_attribute (space => 'preserve',              $node->set_attribute (space => 'preserve',
420                                    namespace_uri => NS_xml_URI);                                    namespace_uri => NS_xml_URI);
421                my $class = $source->get_attribute_value ('class', default => '');
422                $node->set_attribute (class => $class) if length $class;
423            }            }
424            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
425          } elsif ($ln eq 'anchor') {          } elsif ($ln eq 'anchor') {
426            local $opt->{o}->{var}->{sw09__anchor_content} = sub {            local $opt{o}->{var}->{sw09__anchor_content} = sub {
427              $apply_template_children->($source => shift);              $apply_template_children->($source => shift);
428            };            };
429            SuikaWiki::Plugin->module_package ('WikiLinking')            SuikaWiki::Plugin->module_package ('WikiLinking')
430                             ->to_wikipage_in_html ({                             ->to_wikipage_in_html ({
431              label       => SuikaWiki::Plugin->resource              label => $WIKIRESOURCE->get_text
432                               ('Link:SuikaWiki/0.9:toWikiPage:SourceLabel'),                                   (name =>
433                                        'Link:SuikaWiki/0.9:toWikiPage:SourceLabel',
434                                      param => $opt{o},
435                                      wiki => $opt{o}->{wiki}),
436            } => {            } => {
437      ## TODO:              base                => $opt{o}->{wiki}->{var}->{page},
438              page_name_relative  => [split m#//#, $source->inner_text],              page_name_relative  => $opt{o}->{wiki}->name ($source->inner_text),
439              page_anchor_no      => $source->get_attribute_value ('anchor'),              page_anchor_no      => $source->get_attribute_value
440                                         ('anchor',
441                                          namespace_uri => $NS_SW09),
442            }, {            }, {
443              o => $opt->{o},              o => $opt{o},
444              parent => $result,              parent => $result,
445            });            });
446          } elsif ($ln eq 'p') {          } elsif ($ln eq 'p') {
# Line 159  Format: Line 450  Format:
450                                                     local_name => 'p'));                                                     local_name => 'p'));
451          } elsif ($ln eq 'h') {          } elsif ($ln eq 'h') {
452            my $node;            my $node;
453            if ($opt->{o}->{var}->{ws__section_depth} > 6) {            if ($opt{o}->{var}->{ws__section_depth} > 6) {
454              $node = $result->append_new_node              $node = $result->append_new_node
455                                  (type => '#element',                                  (type => '#element',
456                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
457                                   local_name => 'div');                                   local_name => 'div');
458              $node->set_attribute (class => 'heading h'.$opt->{o}->{var}              $node->set_attribute (class => 'heading h'.$opt{o}->{var}
459                                                     ->{ws__section_depth});                                                     ->{ws__section_depth});
460            } else {            } else {
461              $node = $result->append_new_node              $node = $result->append_new_node
462                                  (type => '#element',                                  (type => '#element',
463                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
464                                   local_name => 'h'.$opt->{o}->{var}                                   local_name => 'h'.$opt{o}->{var}
465                                                         ->{ws__section_depth});                                                         ->{ws__section_depth});
466            }            }
467            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
468              $WIKISTRUCT->set_section_id ($result, undef, $opt{o}->{wiki},
469                                                 title => $source->inner_text);
470          } elsif ($ln eq 'ruby' or $ln eq 'rubyb') {          } elsif ($ln eq 'ruby' or $ln eq 'rubyb') {
471            my @child;            my @child;
472            for (@{$source->child_nodes}) {            for (@{$source->child_nodes}) {
# Line 258  Format: Line 551  Format:
551                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
552                                   local_name => 'div');                                   local_name => 'div');
553            $node->set_attribute (class => $ln);            $node->set_attribute (class => $ln);
554            local $opt->{o}->{var}->{ws__section_depth}            local $opt{o}->{var}->{ws__section_depth}
555                = $opt->{o}->{var}->{ws__section_depth} + 1;                = $opt{o}->{var}->{ws__section_depth} + 1;
556            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
557          } elsif ($ln eq 'anchor-end') {          } elsif ($ln eq 'anchor-end') {
558            my $node = $result->append_new_node            my $node = $result->append_new_node
# Line 267  Format: Line 560  Format:
560                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
561                                   local_name => 'a');                                   local_name => 'a');
562            $node->set_attribute (id => 'anchor-'.$source->get_attribute_value            $node->set_attribute (id => 'anchor-'.$source->get_attribute_value
563                                                    ('anchor', default => '0'));                                                    ('anchor', default => '0',
564                                                       namespace_uri => $NS_SW09));
565              $node->set_attribute (name => 'anchor-'.$source->get_attribute_value
566                                                      ('anchor', default => '0',
567                                                       namespace_uri => $NS_SW09))
568                if $opt{o}->{wiki}->{var}->{client}->{downgrade}->{html_no_id};
569            $node->append_text ($source->inner_text);            $node->append_text ($source->inner_text);
570          } elsif ($ln eq 'anchor-internal') {          } elsif ($ln eq 'anchor-internal') {
571            my $node = $result->append_new_node            my $node = $result->append_new_node
# Line 275  Format: Line 573  Format:
573                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
574                                   local_name => 'a');                                   local_name => 'a');
575            $node->set_attribute (href => '#anchor-'.$source->get_attribute_value            $node->set_attribute (href => '#anchor-'.$source->get_attribute_value
576                                                       ('anchor', default => '0'));                                                       ('anchor',
577                                       namespace_uri => $NS_SW09, default => '0'));
578            $node->set_attribute (class => 'wiki-anchor');            $node->set_attribute (class => 'wiki-anchor');
579            $node->append_text ($source->inner_text);            $node->append_text ($source->inner_text);
580            } elsif ($ln eq 'anchor-external') {
581              local $opt{o}->{var}->{sw09__anchor_content} = sub {
582                $apply_template_children->($source => shift);
583              };
584              $WIKILINKING
585                    ->to_resource_in_html (
586                        {
587                         label => $WIKIRESOURCE
588                                    ->get_text (name =>
589                                       'Link:SuikaWiki/0.9:toResource:SourceLabel',
590                                       param => $opt{o},
591                                       wiki => $opt{o}->{wiki}),
592                        }, {
593                          resource_scheme =>
594                            $source->get_attribute_value ('resScheme',
595                                                          namespace_uri => $NS_SW09,
596                                                          default => 'URI'),
597                          resource_parameter =>
598                            $source->get_attribute_value ('resParameter',
599                                                          namespace_uri => $NS_SW09,
600                                                          default => ''),
601                        }, {
602                         o => $opt{o},
603                         parent => $result,
604                        });
605            } elsif ($ln eq 'form') {
606              my $ref = $source->get_attribute_value ('ref', default => 'form');
607              if ($ref eq 'form') {
608                $WIKIFORMCORE->make_content_form_in_html
609                                     ($result,
610                                      $source->get_attribute_value
611                                                        ('input', default => ''),
612                                      option => $source->get_attribute_value
613                                                           ('option'),
614                                      name => $source->get_attribute_value ('id'),
615                                      o => $opt{o},
616                                      wiki => $opt{o}->{wiki},
617                                      output => {
618                                        page => $opt{page},
619                                      });
620              } elsif ($ref eq 'comment') {
621                $WIKIFORMCORE->make_content_form_in_html
622                                     ($result,
623                                      $WIKIRESOURCE->get
624                                        (name => 'SuikaWiki/0.9:form:comment:input',
625                                         o => $opt{o}, wiki => $opt{o}->{wiki}),
626                                      option => $WIKIRESOURCE->get
627                                        (name => 'SuikaWiki/0.9:form:comment:option',
628                                         o => $opt{o}, wiki => $opt{o}->{wiki}),
629                                      name => $source->get_attribute_value ('id'),
630                                      o => $opt{o},
631                                      wiki => $opt{o}->{wiki},
632                                      output => {
633                                        page => $opt{page},
634                                      });
635              } else {
636     ## TODO:
637              }
638          } elsif ($ln eq 'dr') {          } elsif ($ln eq 'dr') {
639            $apply_template_children->($source => $result);            $apply_template_children->($source => $result);
640          } elsif ($ln eq 'document') {          } elsif ($ln eq 'document') {
# Line 290  Format: Line 647  Format:
647                                                     namespace_uri => $NS_XHTML1,                                                     namespace_uri => $NS_XHTML1,
648                                                     local_name => 'div');                                                     local_name => 'div');
649            $body_block->set_attribute (class => 'block SuikaWiki-0-9');            $body_block->set_attribute (class => 'block SuikaWiki-0-9');
           local $opt->{o}->{var}->{ws__section_depth}  
               = $opt->{o}->{var}->{ws__section_depth} + 1;  
650            $apply_template_children->($body => $body_block);            $apply_template_children->($body => $body_block);
651          } else {          } else {
652            my $node = $result->append_new_node            my $node = $result->append_new_node
# Line 314  Format: Line 669  Format:
669          }          }
670        };        };
671                
672        $apply_template_children->($xml => $opt->{-parent});        $apply_template_children->($opt{source} => $opt{parent});
673    
674    
675    @Converter:  Function:
676      @@Type:    @Name: xml_to_text
677        @@@@: application/x-suikawiki+xml    @Main:
678        @@@version: 0.9      my (undef, $src, $opt) = @_;
679      @@Description:  
680        @@@@: Converting SuikaWiki/0.9 text format to XML format  
681        @@@lang: en      my %is_block = (
682      @@Main:        qw/p 1 blockquote 1 pre 1 ul 1 ol 1 dl 1 section 1 h 1
683        __FUNCPACK__->text_to_xml ($source, $opt);           bodytext 1 document 1 head 1 body 1 table 1 text 1 form 1
684             insert 1 delete 1/
685        );
686    
687            my %x2t;
688            %x2t = (
689              anchor => sub {
690                my $source = shift;
691                my $result = '[['
692                          .  $x2t{'#inline'}->($source, no_newline => 1)
693                          .  ']';
694                my $anchor = $source->get_attribute_value
695                                      ('anchor',
696                                       namespace_uri => $NS_SW09,
697                                       default => '');
698                if (length $anchor) {
699                  $result .= '>>'.(0+$anchor);
700                } else {
701                  $anchor = $source->get_attribute_value
702                                      ('resScheme',
703                                       namespace_uri => $NS_SW09);
704                  if ($anchor) {
705                    my $param = $source->get_attribute_value
706                                      ('resParameter',
707                                       namespace_uri => $NS_SW09);
708                    if ($anchor eq 'URI' and $param =~ /^[0-9A-Za-z_+.%-]+:/) {
709                      $result .= '<' . $param . '>';
710                    } else {
711                      $result .= '<' . $anchor . ':' . $param . '>';
712                    }
713                  }
714                }
715                $result . ']';
716              },
717              li => sub {
718                my $source = shift;
719                my $result = ({qw/ul - ol =/}->{$opt->{o}->{var}->{sw09__list_type}}
720                              x $opt->{o}->{var}->{sw09__list_depth})
721                          .  ' ' . $x2t{'#flow'}->($source);
722                $result;
723              },
724              dt => sub {
725                ':' . $x2t{'#inline'}->(return, no_newline => 1) . ':';
726              },
727              h => sub {
728                  ("*" x ($opt->{o}->{var}->{ws__section_depth} - 1))
729                .  " "
730                .  $x2t{'#inline'}->(shift, no_newline => 1);
731              },
732              'anchor-end' => sub {
733                return shift->inner_text;
734              },
735              'anchor-internal' => sub {
736                return shift->inner_text;
737              },
738              'anchor-external' => sub {
739                return '<'.shift->inner_text.'>';
740              },
741              form => sub {
742                my $source = shift;
743                my $ref = $source->get_attribute_value ('ref', default => 'form');
744                my $result = '[[#'.$ref;
745                my $name = $source->get_attribute_value ('id');
746                $name =~ s/([()\\])/\\$1/g;
747                $result .= '(' . $name . ')' if $name;
748                ## General WikiForm
749                if ($ref eq 'form') {
750                  $result .= ":'";
751                  my $input = $source->get_attribute_value ('input', default => '');
752                  $input =~ s/(['\\])/\\$1/g;
753                  $result .= $input . "':'";
754                  my $template = $source->get_attribute_value ('template', default => '');
755                  $template =~ s/(['\\])/\\$1/g;
756                  $result .= $template . "'";
757                  my $option = $source->get_attribute_value ('option');
758                  if ($option) {
759                    $option =~ s/(['\\])/\\$1/g;
760                    $result .= ":'" . $option . "'";
761                  }
762                ## Specific WikiForm
763                } else {
764                  my $param = $source->get_attribute_value ('parameter');
765                  if ($param) {
766                    $result .= ':' . $param;
767                  }
768                }
769                $result .= ']]';
770              },
771              pre => sub {
772                my $source = shift;
773                my $result = '[PRE';
774                my $class = $source->get_attribute_value ('class');
775                if ($class) {
776                  $class =~ s/([\\()])/\\$1/g;
777                  $result .= '(' . $class . ')';
778                }
779                $result .= "[\x0A"
780                        .  $x2t{'#inline'}->($source);
781                $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
782                $result .= "]PRE]\x0A";
783              },
784              insert => sub {
785                my $source = shift;
786                my $result = '[INS';
787                my $class = $source->get_attribute_value ('class');
788                if ($class) {
789                  $class =~ s/([\\()])/\\$1/g;
790                  $result .= '(' . $class . ')';
791                }
792                local $opt->{o}->{var}->{sw09__list_depth} = 0;
793                $result .= "[\x0A"
794                        .  $x2t{'#block'}->($source);
795                $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
796                $result .= "]INS]\x0A";
797              },
798              delete => sub {
799                my $source = shift;
800                my $result = '[DEL';
801                my $class = $source->get_attribute_value ('class');
802                if ($class) {
803                  $class =~ s/([\\()])/\\$1/g;
804                  $result .= '(' . $class . ')';
805                }
806                local $opt->{o}->{var}->{sw09__list_depth} = 0;
807                $result .= "[\x0A"
808                        .  $x2t{'#block'}->($source);
809                $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
810                $result .= "]DEL]\x0A";
811              },
812              document => sub {
813                my $source = shift;
814                my $result = '#?'
815                           . $source->get_attribute_value
816                                        ('Name', namespace_uri => $NS_SW09,
817                                         default => 'SuikaWiki')
818                           . '/'
819                           . $source->get_attribute_value
820                                        ('Version', namespace_uri => $NS_SW09,
821                                         default => '0.9');
822                for (@{$source->child_nodes}) {
823                  $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_)
824                    if $_->node_type eq '#element';
825                }
826                $result;
827              },
828              head => sub {
829                my $source = shift;
830                my $result = '';
831                for (@{$source->child_nodes}) {
832                  if ($_->node_type eq '#element' and
833                      $_->local_name eq 'parameter') {
834                    $result .= ' '.$x2t{parameter}->($_);
835                  }
836                }
837                $result . "\x0A";
838              },
839              parameter => sub {
840                my $source = shift;
841                my $result = $source->get_attribute_value ('name', default => '')
842                          .  '="';
843                my @v;
844                for (@{$source->child_nodes}) {
845                  push @v, $x2t{value}->($_) if $_->node_type eq '#element' and
846                                                $_->local_name eq 'value';
847                }
848                $result .= join ',', @v;
849                $result .  '"';
850              },
851              value => sub {
852                my $value = $x2t{'#inline'}->(shift, no_newline => 1);
853                $value =~ s/(["\\])/\\$1/g;
854                $value =~ tr/\x0A\x0D/ /;
855                $value;
856              },
857              section => sub {
858                local $opt->{o}->{var}->{ws__section_depth}
859                    = $opt->{o}->{var}->{ws__section_depth} + 1;
860                $x2t{'#block'}->(shift);
861              },
862              body => sub {
863                local $opt->{o}->{var}->{ws__section_depth} = 1;
864                $x2t{'#block'}->(shift);
865              },
866              text => sub {
867                my ($source, %opt) = @_;
868                my $result .= '';
869                for (@{$source->child_nodes}) {
870                  if ($_->node_type eq '#text') {
871                    $result .= $_->inner_text;
872                  } elsif ($_->node_type eq '#element') {
873                    $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_);
874                  }
875                }
876                $result;
877              },
878              dr => sub {
879                my $result = $x2t{'#list'}->(shift);
880                if ($result) {
881                  $result . "\x0A";
882                } else {
883                  "::\x0A";
884                }
885              },
886              dt => sub {
887                ':' . $x2t{'#inline'}->(shift, no_newline => 1) . ':';
888              },
889              dd => sub {
890                $x2t{'#inline'}->(shift);
891              },
892              tr => sub {
893                my $result = $x2t{'#list'}->(shift);
894                if ($result) {
895                  substr ($result, 1) . "\x0A";
896                } else {
897                 "',\x0A";
898                }
899              },
900              td => sub {
901                my $source = shift;
902                my $result = $x2t{'#inline'}->($source, no_newline => 1);
903                if ($result =~ /[,"\\]/ or $result =~ /==/) {
904                  $result =~ s/(["\\])/\\$1/g;
905                  $result = '"' . $result . '"';
906                }
907                my $colspan = $source->get_attribute_value ('colspan', default => 1);
908                $result .= ("\t,==" x ($colspan - 1)) if $colspan > 1;
909                "\t," . $result;
910              },
911              em => sub {
912                "''" . $x2t{'#inline'}->($_, no_newline => 1) . "''";
913              },
914              strong => => sub {
915                "'''" . $x2t{'#inline'}->($_, no_newline => 1) . "'''";
916              },
917              rb => sub {
918                $x2t{'#inline'}->(shift, no_newline => 1);
919              },
920              rt => sub {
921                '] [' . $x2t{'#inline'}->(shift, no_newline => 1);
922              },
923              replace => sub {
924                '__&&' . shift->get_attribute_value ('by', default => '') . '&&__';
925              },
926              bodytext => sub {
927                my ($source, %opt) = @_;
928                local $opt->{o}->{var}->{sw09__bq_depth}
929                    = $opt->{o}->{var}->{sw09__bq_depth} + 1;
930                my @result;
931                for (@{$source->child_nodes}) {
932                  if ($_->node_type eq '#element') {
933                    my $ln = $_->local_name;
934                    push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
935                                   $ln];
936                  }
937                }
938                my $result = '';
939                my $prev = '';
940                for (@result) {
941                  my $s = $_->[0];
942                  if ($_->[1] eq 'p') {
943                    $result .= "\x0A" if length $result and
944                                         substr ($result, -1) ne "\x0A";
945                    $result .= ('>' x $opt->{o}->{var}->{sw09__bq_depth}) . ' ';
946                  } elsif ($_->[1] eq 'form' or $_->[1] eq 'replace') {
947                    $result .= "\x0A" if length $result and
948                                         substr ($result, -1) ne "\x0A";
949                    $result .= ('>' x $opt->{o}->{var}->{sw09__bq_depth})."\x0A";
950                  } elsif ($_->[1] eq 'blockquote' or $_->[1] eq 'text') {
951                    $result .= "\x0A" if length $result and
952                                         substr ($result, -1) ne "\x0A";
953                  } else {
954                    unless ($prev eq 'text') {
955                      $result .= "\x0A" if length $result and
956                                           substr ($result, -1) ne "\x0A";
957                    }
958                    $result .= ('>' x $opt->{o}->{var}->{sw09__bq_depth})."\x0A";
959                  }
960                  $result .= $s;
961                  $prev = $_->[1];
962                }
963                $result;
964              },
965              ## Note: This element will be interpreted as a paragraph
966              ##       unless format is SuikaWikiImage/0.9.
967              image => sub {
968                my ($source, %opt) = @_;
969                return "\x0A__IMAGE__\x0A" . $source->inner_text . "\x0A";
970              },
971              '#block' => sub {
972                my ($source, %opt) = @_;
973                my @result;
974                for (@{$source->child_nodes}) {
975                  if ($_->node_type eq '#element') {
976                    my $ln = $_->local_name;
977                    push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
978                                   $ln];
979                  }
980                }
981                my $result = '';
982                my $prev = '';
983                for (@result) {
984                  my $s = $_->[0];
985                  if ($_->[1] eq 'form') {
986                    $result .= "\x0A" if length $result and
987                                         substr ($result, -1) ne "\x0A";
988                    $result .= "\x0A";
989                  } elsif ($_->[1] eq 'replace') {
990                    $result .= "\x0A" if length $result and
991                                         substr ($result, -1) ne "\x0A";
992                  } elsif ($_->[1] eq 'text') {
993                    $result .= "\x0A" if length $result and
994                                         substr ($result, -1) ne "\x0A";
995                    $result .= "\x0A" if $prev eq 'p';
996                  } else {
997                    if ($prev ne 'text' and $prev ne 'replace') {
998                      $result .= "\x0A" if length $result and
999                                           substr ($result, -1) ne "\x0A";
1000                      $result .= "\x0A";
1001                    }
1002                  }
1003                  $result .= $s;
1004                  $prev = $_->[1];
1005                }
1006                $result;
1007              },
1008              '#flow' => sub {
1009                my ($source, %opt) = @_;
1010                my @result;
1011                for (@{$source->child_nodes}) {
1012                  if ($_->node_type eq '#element') {
1013                    my $ln = $_->local_name;
1014                    if ($is_block{$ln}) {
1015                      push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
1016                                     $ln];
1017                    } else {
1018                      if (@result and ($result[$#result]->[1] eq '#inline')) {
1019                        $result[$#result]->[0]
1020                          .= ($x2t{$ln} or $x2t{'#undef'})->($_);
1021                      } else {
1022                        push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
1023                                       '#inline'];
1024                      }
1025                    }
1026                  } elsif ($_->node_type eq '#text') {
1027                    if (@result and ($result[$#result]->[1] eq '#inline')) {
1028                      $result[$#result]->[0] .= $_->inner_text;
1029                    } else {
1030                      push @result, [$_->inner_text, '#inline'];
1031                    }
1032                  }
1033                }
1034                my $result = '';
1035                my $prev = '';
1036                for (@result) {
1037                  my $s = $_->[0];
1038                  if ($_->[1] eq '#inline') {
1039                    if ($prev ne 'text' and $prev ne 'form' and $prev ne 'replace') {
1040                      $result .= "\x0A" if length $result and
1041                                           substr ($result, -1) ne "\x0A";
1042                    }
1043                    $s =~ s/\x0D\x0A/\x0A/g;
1044                    $s =~ s/\x0D/\x0A/g;
1045                    $s =~ s/\x0A\x0A+/\x0A/g;
1046                    $s =~ s/\x0A/\x20/g if $opt{no_newline};
1047                  } elsif ($_->[1] eq 'form' or $_->[1] eq 'replace') {
1048                    if ($prev ne '#inline') {
1049                      $result .= "\x0A" if length $result and
1050                                           substr ($result, -1) ne "\x0A";
1051                    }
1052                  } elsif ($_->[1] eq 'text') {
1053                    $result .= "\x0A" if length $result and
1054                                         substr ($result, -1) ne "\x0A";
1055                  } else {
1056                    unless ($prev eq 'text') {
1057                      $result .= "\x0A" if length $result and
1058                                           substr ($result, -1) ne "\x0A";
1059                    }
1060                  }
1061                  $result .= $s;
1062                  $prev = $_->[1];
1063                }
1064                $result;
1065              },
1066              '#inline' => sub {
1067                my ($source, %opt) = @_;
1068                my $result .= '';
1069                for (@{$source->child_nodes}) {
1070                  if ($_->node_type eq '#text') {
1071                    $result .= $_->inner_text;
1072                  } elsif ($_->node_type eq '#element') {
1073                    $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_);
1074                  }
1075                }
1076                $result =~ s/\x0D\x0A/\x0A/g;
1077                $result =~ s/\x0D/\x0A/g;
1078                $result =~ s/\x0A\x0A+/\x0A/g;
1079                $result =~ s/\x0A/\x20/g if $opt{no_newline};
1080                $result;
1081              },
1082              '#list' => sub {
1083                my ($source, %opt) = @_;
1084                my $result .= '';
1085                for (@{$source->child_nodes}) {
1086                  if ($_->node_type eq '#element') {
1087                    $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_);
1088                  }
1089                }
1090                $result;
1091              },
1092              '#undef' => sub {
1093                my $source = shift;
1094                ## TODO:
1095                "<".$source->namespace_uri.">:".$source->local_name
1096                      .  $x2t{'#inline'}->($source);
1097              },
1098            );
1099            for (qw/blockquote dl tbody table/) {
1100              $x2t{$_} = sub { $x2t{'#list'}->(shift) };
1101            }
1102            for (qw/p dd/) {
1103              $x2t{$_} = sub { $x2t{'#flow'}->(shift) };
1104            }
1105            for my $type (qw/ul ol/) {
1106              $x2t{$type} = sub {
1107                my $source = shift;
1108                local $opt->{o}->{var}->{sw09__list_type} = $type;
1109                local $opt->{o}->{var}->{sw09__list_depth}
1110                    = $opt->{o}->{var}->{sw09__list_depth} + 1;
1111                my @result;
1112                for (@{$source->child_nodes}) {
1113                  push @result, $x2t{$_->local_name}->($_)
1114                    if $_->node_type eq '#element';
1115                }
1116                my $result = '';
1117                for (@result) {
1118                  $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
1119                  $result .= $_;
1120                }
1121                substr ($result, 1);
1122              };
1123            }
1124            for my $type (qw/code samp var dfn kbd sub sup weak q ruby rubyb
1125                             abbr ins del/) {
1126              $x2t{$type} = sub {
1127                my $source = shift;
1128                my $result = '['.uc $type;
1129                my $class = $source->get_attribute_value ('class', default => '');
1130                if ($class) {
1131                  $class =~ s/([()\\])/\\$1/g;
1132                  $result .= '(' . $class . ')';
1133                }
1134                $result .= '['
1135                        .  $x2t{'#inline'}->($source, no_newline => 1)
1136                        .  ']';
1137                my $anchor = $source->get_attribute_value
1138                                      ('anchor',
1139                                       namespace_uri => $NS_SW09,
1140                                       default => '');
1141                if (length $anchor) {
1142                  $result .= '>>'.(0+$anchor);
1143                } else {
1144                  $anchor = $source->get_attribute_value
1145                                      ('resScheme',
1146                                       namespace_uri => $NS_SW09);
1147                  if ($anchor) {
1148                    my $param = $source->get_attribute_value
1149                                      ('resParameter',
1150                                       namespace_uri => $NS_SW09);
1151                    if ($anchor eq 'URI' and $param =~ /^[0-9A-Za-z_+.%-]+:/) {
1152                      $result .= '<' . $param . '>';
1153                    } else {
1154                      $result .= '<' . $anchor . ':' . $param . '>';
1155                    }
1156                  }
1157                }
1158                $result .= ']';
1159                $result;
1160              };
1161            }
1162    
1163        $x2t{'#list'}->($src);
1164    
1165    Function:
1166      @Name: get_nth_element
1167      @Main:
1168        my (undef, $node, $ns => $ln, $n) = @_;
1169        return $n if $n < 1;
1170        if ($node->node_type eq '#element' and
1171            $node->namespace_uri eq $ns and
1172            $node->local_name eq $ln) {
1173          return $node unless --$n;
1174        }
1175        for (@{$node->child_nodes}) {
1176          if ($_->node_type eq '#element') {
1177            if ($_->namespace_uri eq $ns and
1178                $_->local_name eq $ln) {
1179              return $_ unless --$n;
1180            } else {
1181              $n = __FUNCPACK__->get_nth_element ($_, $ns => $ln, $n);
1182              return $n if ref $n;
1183            }
1184          } elsif ($_->node_type eq '#fragment' or $_->node_type eq '#document') {
1185            $n = __FUNCPACK__->get_nth_element ($_, $ns => $ln, $n);
1186            return $n if ref $n;
1187          }
1188        }
1189        return $n;
1190    
1191    Function:
1192      @Name: get_element_by_id
1193      @Main:
1194        my (undef, $node, $id) = @_;
1195        return $node if $node->node_type eq '#element'
1196                    and $node->get_attribute_value ('id', default_value => '')
1197                     eq $id;
1198        for (@{$node->child_nodes}) {
1199          if ({'#element'=>1, '#fragment'=>1, '#document'=>1}->{$_->node_type}) {
1200            my $r = __FUNCPACK__->get_element_by_id ($_, $id);
1201            return $r if $r;
1202          }
1203        }
1204    
1205  Function:  Function:
1206    @Name: text_to_xml    @Name: text_to_xml
# Line 345  Function: Line 1220  Function:
1220      my $head = $root->append_new_node (type => '#element',      my $head = $root->append_new_node (type => '#element',
1221                                         namespace_uri => $NS_XHTML2,                                         namespace_uri => $NS_XHTML2,
1222                                         local_name => 'head');                                         local_name => 'head');
1223      if ($source =~ s#^\#\?SuikaWiki/0\.9\b((?>.*))\s*##) {      $root->append_text ("\x0A");
1224        my $param = $1;      my $body = $root->append_new_node (type => '#element',
1225                                           namespace_uri => $NS_XHTML2,
1226                                           local_name => 'body');
1227        $root->append_text ("\x0A");
1228    
1229        if ($source =~ s#^\#\?(SuikaWiki(?:Image)?)/0\.9\b((?>.*))\s*##) {
1230          my $type = $1;
1231          my $param = $2;
1232          $root->set_attribute (Name => $type, namespace_uri => $NS_SW09);
1233          $root->set_attribute (Version => '0.9', namespace_uri => $NS_SW09);
1234        while ($param =~ /\G\s+([a-z-]+)="((?>[^"\\]*)(?>(?>[^"\\]+|\\.)*))"/g) {        while ($param =~ /\G\s+([a-z-]+)="((?>[^"\\]*)(?>(?>[^"\\]+|\\.)*))"/g) {
1235          my ($name, $value) = ($1, $2);          my ($name, $value) = ($1, $2);
1236          $value =~ s/\\(.)/$1/g;          $value =~ s/\\(.)/$1/g;
1237          for ($head->append_new_node (type => '#element',          for ($head->append_new_node (type => '#element',
1238                                       namespace_uri => $NS_SW09,                                       namespace_uri => $NS_SW09,
1239                                       local_name => 'parmeter')) {                                       local_name => 'parameter')) {
1240            $_->set_attribute (name => $name);            $_->set_attribute (name => $name);
1241            for my $value (split /,/, $value) {            for my $value (split /,/, $value) {
1242              $_->append_new_node (type => '#element',              $_->append_new_node (type => '#element',
# Line 363  Function: Line 1247  Function:
1247          }          }
1248          $head->append_text ("\x0A");          $head->append_text ("\x0A");
1249        }        }
1250          
1251          if ($type eq 'SuikaWikiImage') {
1252            $source =~ s/\x0A__IMAGE__\x0A(.*)$//s;
1253            if (my $image = $1) {
1254              $image =~ s/^\s+//;
1255              $image =~ s/\s+$//;
1256              $root->append_new_node
1257                       (type => '#element',
1258                        namespace_uri => $NS_SW09,
1259                        local_name => 'image')
1260                   ->append_text ($image);
1261              $root->append_text ("\x0A");
1262            }
1263          }
1264      } else {      } else {
1265          $root->set_attribute (Name => 'SuikaWiki', namespace_uri => $NS_SW09);
1266          $root->set_attribute (Version => '0.9', namespace_uri => $NS_SW09);
1267        ## TODO: warn        ## TODO: warn
1268      }      }
     $root->append_text ("\x0A");  
1269            
1270      my $body = $root->append_new_node (type => '#element',      __FUNCPACK__->block_text_to_xml (\$source => $body, opt => $opt);
                                        namespace_uri => $NS_XHTML2,  
                                        local_name => 'body');  
     __FUNCPACK__->block_text_to_xml (\$source => $body);  
1271    
1272  Function:  Function:
1273    @Name:block_text_to_xml    @Name:block_text_to_xml
# Line 382  Function: Line 1278  Function:
1278      @@lang:en      @@lang:en
1279    @Main:    @Main:
1280      my (undef, $source, $current, %opt) = @_;      my (undef, $source, $current, %opt) = @_;
1281      my %depth;      my %depth = %{$opt{depth} || {}};
1282      my $back_to_section = sub {      my $back_to_section = sub {
1283        my $cur_type = $current->local_name;        my $cur_type = $current->local_name;
1284        while (not (        while (not (
1285                    $cur_type eq 'section'                    $cur_type eq 'section'
1286                 or $cur_type eq 'body'                 or $cur_type eq 'body'
1287                 or $cur_type eq 'bodytext'                 or $cur_type eq 'bodytext'
1288                 or $cur_type eq 'ins'                 or $cur_type eq 'insert'
1289                 or $cur_type eq 'del'                 or $cur_type eq 'delete'
1290                   )                   )
1291        ) {        ) {
1292          $current = $current->parent_node;          $current = $current->parent_node;
# Line 403  Function: Line 1299  Function:
1299        while (not (        while (not (
1300                    $cur_type eq 'section'                    $cur_type eq 'section'
1301                 or $cur_type eq 'body'                 or $cur_type eq 'body'
1302                 or $cur_type eq 'ins'                 or $cur_type eq 'insert'
1303                 or $cur_type eq 'del'                 or $cur_type eq 'delete'
1304                   )                   )
1305              ) {              ) {
1306          $current = $current->parent_node;          $current = $current->parent_node;
# Line 465  Function: Line 1361  Function:
1361          $current = $current->append_new_node (type => '#element',          $current = $current->append_new_node (type => '#element',
1362                                                namespace_uri => $NS_XHTML2,                                                namespace_uri => $NS_XHTML2,
1363                                                local_name => 'li');                                                local_name => 'li');
1364          __FUNCPACK__->inline_text_to_xml (\$line => $current);          __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1365        } elsif ($line =~ s/^(\*+)\s*//) {        } elsif ($line =~ s/^(\*+)\s*//) {
1366          my $depth = length $1;          my $depth = length $1;
1367          $back_to_real_section->();          $back_to_real_section->();
# Line 491  Function: Line 1387  Function:
1387          __FUNCPACK__->inline_text_to_xml (\$line =>          __FUNCPACK__->inline_text_to_xml (\$line =>
1388            $current->append_new_node (type => '#element',            $current->append_new_node (type => '#element',
1389                                       namespace_uri => $NS_XHTML2,                                       namespace_uri => $NS_XHTML2,
1390                                       local_name => 'h')                                       local_name => 'h'), %opt,
1391          );          );
1392        } elsif ($line =~ s/^(?!>>[0-9])(>+)\s*//) {        } elsif ($line =~ s/^(?!>>[0-9])(>+)\s*//) {
1393          my $depth = length $1;          my $depth = length $1;
# Line 523  Function: Line 1419  Function:
1419                                   (type => '#element',                                   (type => '#element',
1420                                    namespace_uri => $NS_XHTML2,                                    namespace_uri => $NS_XHTML2,
1421                                    local_name => 'p');                                    local_name => 'p');
1422            __FUNCPACK__->inline_text_to_xml (\$line => $current);            __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1423          }          }
1424        } elsif ($line =~ s/^(?>:\s*)([^:]+?)\s*:\s*//) {        } elsif ($line =~ s/^(?>:\s*)([^:]+?)\s*:\s*//) {
1425          my $parent_type = $current->local_name;          my $parent_type = $current->local_name;
# Line 542  Function: Line 1438  Function:
1438          __FUNCPACK__->inline_text_to_xml (\"$1" =>          __FUNCPACK__->inline_text_to_xml (\"$1" =>
1439            $current->append_new_node (type => '#element',            $current->append_new_node (type => '#element',
1440                                       namespace_uri => $NS_XHTML2,                                       namespace_uri => $NS_XHTML2,
1441                                       local_name => 'dt')                                       local_name => 'dt'), %opt,
1442          );          );
1443          $current->append_text ("\x0A");          $current->append_text ("\x0A");
1444          $current = $current->append_new_node (type => '#element',          $current = $current->append_new_node (type => '#element',
1445                                                namespace_uri => $NS_XHTML2,                                                namespace_uri => $NS_XHTML2,
1446                                                local_name => 'dd');                                                local_name => 'dd');
1447            __FUNCPACK__->inline_text_to_xml (\$line => $current);            __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1448        } elsif ($line =~ /^\[(INS|DEL)(\([^()\\]*\))?\[\s*$/) {        } elsif ($line =~ /^\[(INS|DEL)(?>(\([^()\\]*\))?)\[\s*$/) {
1449          $current->append_text ("\x0A");          $current->append_text ("\x0A");
1450          my $mod = $current->append_new_node (type => '#element',          my $mod = $current->append_new_node
1451                                               namespace_uri => $NS_XHTML1,                                (type => '#element',
1452                                               local_name => lc $1);                                 namespace_uri => $NS_SW09,
1453                                   local_name => {qw/INS insert DEL delete/}->{$1});
1454          $mod->set_attribute (class => $2) if $2;          $mod->set_attribute (class => $2) if $2;
1455          __FUNCPACK__->block_text_to_xml ($source => $mod,          __FUNCPACK__->block_text_to_xml ($source => $mod, %opt,
1456                                           'return_by_'.$1 => 1);                                           'return_by_'.$1 => 1,
1457                                             depth => \%depth);
1458        } elsif ($line =~ /^\](INS|DEL)\]\s*$/) {        } elsif ($line =~ /^\](INS|DEL)\]\s*$/) {
1459          if ($opt{'return_by_'.$1}) {          if ($opt{'return_by_'.$1}) {
1460            return;            return;
1461          } else {          } else {
1462            ## TODO: warn            ## TODO: warn
1463          }          }
1464        } elsif ($line =~ /^\[PRE(\([^()\\]*\))?\[\s*$/) {        } elsif ($line =~ /^\[PRE(?>(?>\(((?>[^()\\]*)(?>(?>[^()\\]+|\\.)*))\))?)\[\s*$/) {
1465          $current->append_text ("\x0A");          $current->append_text ("\x0A");
1466          my $pre = $current->append_new_node (type => '#element',          my $pre = $current->append_new_node (type => '#element',
1467                                               namespace_uri => $NS_XHTML1,                                               namespace_uri => $NS_XHTML1,
# Line 578  Function: Line 1476  Function:
1476              last;              last;
1477            } else {            } else {
1478              $f ? undef $f : $pre->append_text ("\x0A");              $f ? undef $f : $pre->append_text ("\x0A");
1479              __FUNCPACK__->inline_text_to_xml (\$line => $pre);              __FUNCPACK__->inline_text_to_xml (\$line => $pre, %opt);
1480            }            }
1481          }          }
1482          if (ref $pre) {          if (ref $pre) {
# Line 590  Function: Line 1488  Function:
1488                                               namespace_uri => $NS_XHTML1,                                               namespace_uri => $NS_XHTML1,
1489                                               local_name => 'pre');                                               local_name => 'pre');
1490          $pre->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI);          $pre->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI);
1491          __FUNCPACK__->inline_text_to_xml (\$line => $pre);          __FUNCPACK__->inline_text_to_xml (\$line => $pre, %opt);
1492          while ($$source =~ /\G([^\x0A]*)\x0A/gc) {          while ($$source =~ /\G([^\x0A]*)\x0A/gc) {
1493            my $line = $1;            my $line = $1;
1494            if (length $line == 0) {            if (length $line == 0) {
1495              pos ($$source) -= 1;              pos ($$source) -= 1;
1496              last;              last;
1497              } elsif ($opt{return_by_INS} and $line =~ /^\]INS\]\s*$/) {
1498                return;
1499              } elsif ($opt{return_by_DEL} and $line =~ /^\]DEL\]\s*$/) {
1500                return;
1501            } else {            } else {
1502              $pre->append_text ("\x0A");              $pre->append_text ("\x0A");
1503              __FUNCPACK__->inline_text_to_xml (\$line => $pre);              __FUNCPACK__->inline_text_to_xml (\$line => $pre, %opt);
1504            }            }
1505          }          }
1506        } elsif ($line =~ /^,/) {        } elsif ($line =~ /^,/) {
# Line 609  Function: Line 1511  Function:
1511                              ->append_new_node (type => '#element',                              ->append_new_node (type => '#element',
1512                                                 namespace_uri => $NS_XHTML2,                                                 namespace_uri => $NS_XHTML2,
1513                                                 local_name => 'tbody');                                                 local_name => 'tbody');
1514          __FUNCPACK__->tablerow_text_to_xml (\$line => $tbody);          __FUNCPACK__->tablerow_text_to_xml (\$line => $tbody, %opt);
1515          while ($$source =~ /\G(,[^\x0A]*)\x0A/gc) {          while ($$source =~ /\G(,[^\x0A]*)\x0A/gc) {
1516            __FUNCPACK__->tablerow_text_to_xml (\"$1" => $tbody);            __FUNCPACK__->tablerow_text_to_xml (\"$1" => $tbody, %opt);
1517          }          }
1518        } else {        } else {
1519          my $current_type = $current->local_name;          my $current_type = $current->local_name;
1520          if ($current_type eq 'section'          if ($current_type eq 'section'
1521           or $current_type eq 'body'           or $current_type eq 'body'
1522           or $current_type eq 'bodytext'           or $current_type eq 'bodytext'
1523           or $current_type eq 'ins'           or $current_type eq 'insert'
1524           or $current_type eq 'del') {           or $current_type eq 'delete') {
1525            $current->append_text ("\x0A");            $current->append_text ("\x0A");
1526            if ($line =~ s/^__&&([^&]+)&&__//) {            if ($line =~ s/^__&&([^&]+)&&__//) {
1527              $current->append_new_node (type => '#element',              $current->append_new_node (type => '#element',
# Line 632  Function: Line 1534  Function:
1534                                              local_name => 'form')) {                                              local_name => 'form')) {
1535                $_->set_attribute (id => $1) if $1;                $_->set_attribute (id => $1) if $1;
1536                my ($i, $t, $o) = ($2, $3 || '', $4 || '');                my ($i, $t, $o) = ($2, $3 || '', $4 || '');
1537                s/\\(.)/$1/g for $i, $t, $o;                s/\\(.)/$1/g for ($i, $t, $o);
1538                $_->set_attribute (input => $i);                $_->set_attribute (input => $i);
1539                $_->set_attribute (template => $t);                $_->set_attribute (template => $t);
1540                $_->set_attribute (option => $o);                $_->set_attribute (option => $o);
# Line 646  Function: Line 1548  Function:
1548                $_->set_attribute (parameter => $3) if defined $3;                $_->set_attribute (parameter => $3) if defined $3;
1549              }              }
1550            }            }
1551            $current = $current->append_new_node            if (length $line) {
1552                                   (type => '#element',              $current = $current->append_new_node
1553                                    namespace_uri => $NS_XHTML2,                                     (type => '#element',
1554                                    local_name => 'p');                                      namespace_uri => $NS_XHTML2,
1555            __FUNCPACK__->inline_text_to_xml (\$line => $current);                                      local_name => 'p');
1556                __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1557              }        
1558          } else {          } else {
1559            $current->append_text (" "); # replacement of prev.line's \n            $current->append_text ("\x0A"); # replacement of prev.line's \n
1560            __FUNCPACK__->inline_text_to_xml (\$line => $current);            __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1561          }          }
1562        }        }
1563      }      }
# Line 676  Function: Line 1580  Function:
1580                                            local_name => 'tr');                                            local_name => 'tr');
1581      my $prev_cell;      my $prev_cell;
1582      while ($$source =~ /\G,\s*/gc) {      while ($$source =~ /\G,\s*/gc) {
1583        $$source =~ /\G([^,"]+|"(?>[^"\\]*)(?>(?>[^"\\]+|\\.)*)"\s*)/gc;        $$source =~ /\G([^,"][^,]*|"(?>[^"\\]*)(?>(?>[^"\\]+|\\.)*)"\s*)/gc;
1584        my $cell = $1;        my $cell = $1;
1585        if ($cell =~ s/^"//) {        if ($cell =~ s/^"//) {
1586          $cell =~ s/"\s*$//g;          $cell =~ s/"\s*$//g;
# Line 698  Function: Line 1602  Function:
1602                                 (type => '#element',                                 (type => '#element',
1603                                  namespace_uri => $NS_XHTML2,                                  namespace_uri => $NS_XHTML2,
1604                                  local_name => 'td');                                  local_name => 'td');
1605        __FUNCPACK__->inline_text_to_xml (\$cell => $prev_cell);        __FUNCPACK__->inline_text_to_xml (\$cell => $prev_cell, %opt);
1606      }      }
1607      # TODO: warn      # TODO: warn
1608    
# Line 709  Function: Line 1613  Function:
1613        SuikaWiki/0.9 text format to XML representation - inline level elements        SuikaWiki/0.9 text format to XML representation - inline level elements
1614      @@lang:en      @@lang:en
1615    @Main:    @Main:
1616        my (undef, $source => $current, %opt) = @_;
1617    
1618    my $ElementDef = {    my $ElementDef = {
1619      ABBR    => {ln => 'abbr', ns_uri => $NS_SW09},      ABBR    => {ln => 'abbr', ns_uri => $NS_XHTML2},
1620      CODE    => {ln => 'code', ns_uri => $NS_XHTML2},      CODE    => {ln => 'code', ns_uri => $NS_XHTML2},
1621      DEL     => {ln => 'del',  ns_uri => $NS_XHTML1},      DEL     => {ln => 'del',  ns_uri => $NS_XHTML1},
1622      DFN     => {ln => 'dfn',  ns_uri => $NS_XHTML2},      DFN     => {ln => 'dfn',  ns_uri => $NS_XHTML2},
# Line 732  Function: Line 1638  Function:
1638      rt      => {ln => 'rt',   ns_uri => $NS_XHTML2, is_nested => 1},      rt      => {ln => 'rt',   ns_uri => $NS_XHTML2, is_nested => 1},
1639    };    };
1640    
     my (undef, $source => $current, %opt) = @_;  
1641      if ($$source =~ /\G\[([0-9]+)\]/gc) {      if ($$source =~ /\G\[([0-9]+)\]/gc) {
1642        for ($current->append_new_node (type => '#element',        for ($current->append_new_node (type => '#element',
1643                                        namespace_uri => $NS_SW09,                                        namespace_uri => $NS_SW09,
1644                                        local_name => 'anchor-end')) {                                        local_name => 'anchor-end')) {
1645          $_->set_attribute (anchor => 0+$1);          $_->set_attribute (anchor => 0+$1,
1646                               namespace_uri => $NS_SW09);
1647          $_->append_text ('['.$1.']');          $_->append_text ('['.$1.']');
1648        }        }
1649      }      }
# Line 749  Function: Line 1655  Function:
1655                                                local_name => 'form');                                                local_name => 'form');
1656          if ($$source =~ /\G$Reg_Form_Content_M\]\]/ogc) {          if ($$source =~ /\G$Reg_Form_Content_M\]\]/ogc) {
1657            $form->set_attribute (id => $1) if $1;            $form->set_attribute (id => $1) if $1;
1658            $form->set_attribute (input => $2);            my ($i, $t, $o) = ($2, $3, $4);
1659            $form->set_attribute (template => $3);            s/\\(.)/$1/g for ($i, $t, $o);
1660            $form->set_attribute (option => $4);            $form->set_attribute (input => $i);
1661              $form->set_attribute (template => $t);
1662              $form->set_attribute (option => $o);
1663          } elsif ($$source =~ /\G$Reg_Embed_Content_M\]\]/ogc) {          } elsif ($$source =~ /\G$Reg_Embed_Content_M\]\]/ogc) {
1664            $form->set_attribute (ref => $1);            $form->set_attribute (ref => $1);
1665            $form->set_attribute (id => $2) if $2;            $form->set_attribute (id => $2) if $2;
1666            $form->set_attribute (parameter => $3) if defined $3;            $form->set_attribute (parameter => $3) if defined $3;
1667          } else {          } else {
1668            ## TODO: error            ## TODO: error
1669            CORE::die $$source;            SuikaWiki::Plugin->module_package('Error')->report_error_simple ($opt{opt}->{o}->{wiki}, InvalidForm => substr ($$source, pos ($$source)));
1670          }          }
1671        } elsif ($$source =~ /\G\[(?>([A-Z]+)(?>\(([^)]*)\))?)?\[/gc) {        } elsif ($$source =~ /\G\[(?>([A-Z]+)(?>\(((?>[^()\\]*)(?>(?>[^()\\]+|\\.)*))\))?)?\[/gc) {
1672          my $type = $1 || 'anchor';          my $type = $1 || 'anchor';
1673          my $param = $2;          my $param = $2;
1674          my $def = $ElementDef->{ $type };          my $def = $ElementDef->{ $type };
1675          unless ($def) {          unless ($def) {
1676            ## TODO: error            ## TODO: error
1677              $def = $ElementDef->{CODE};
1678          }          }
1679          $current = $current->append_new_node (type => '#element',          $current = $current->append_new_node (type => '#element',
1680                                                namespace_uri => $def->{ns_uri},                                                namespace_uri => $def->{ns_uri},
# Line 789  Function: Line 1698  Function:
1698          }          }
1699          my $def = $ElementDef->{$current->local_name} || {};          my $def = $ElementDef->{$current->local_name} || {};
1700          if (defined $anchor) {          if (defined $anchor) {
1701            if ($def->{has_fragment_no}) {            $current->set_attribute (anchor => $anchor + 0,
1702              $current->set_attribute (anchor => $anchor + 0);                                     namespace_uri => $NS_SW09);
           } else {  
             $current->set_attribute (anchor => $anchor + 0,  
                                      namespace_uri => $NS_SW09);  
           }  
1703          } elsif (defined $scheme) {          } elsif (defined $scheme) {
1704            if ($def->{has_cite}) {            if ($scheme =~ /[A-Z]/) {
1705              $current->set_attribute (cite => "$scheme:$opaque");              $current->set_attribute (resScheme => $scheme,
1706                                         namespace_uri => $NS_SW09);
1707                $current->set_attribute (resParameter => $opaque,
1708                                         namespace_uri => $NS_SW09);
1709            } else {            } else {
1710              $current->set_attribute (cite => "$scheme:$opaque",              $current->set_attribute (resScheme => 'URI',
1711                                         namespace_uri => $NS_SW09);
1712                $current->set_attribute (resParameter => "$scheme:$opaque",
1713                                       namespace_uri => $NS_SW09);                                       namespace_uri => $NS_SW09);
1714            }            }
1715          }          }
1716          $current = $current->parent_node;          $current = $current->parent_node;
1717          $current = $current->parent_node if $def->{is_nested};          $current = $current->parent_node if $def->{is_nested};
1718          $depth--;          $depth--;
1719        } elsif ($$source =~ /\G\]\s+\[/gc) {        } elsif ($$source =~ /\G\]\s*\[/gc) {
1720          if ($current->local_name eq 'rb' or $current->local_name eq 'rt') {          if ($current->local_name eq 'rb' or $current->local_name eq 'rt') {
1721            $current = $current->parent_node            $current = $current->parent_node
1722                               ->append_new_node                               ->append_new_node
# Line 814  Function: Line 1724  Function:
1724                                    namespace_uri => $ElementDef->{rt}->{ns_uri},                                    namespace_uri => $ElementDef->{rt}->{ns_uri},
1725                                    local_name => $ElementDef->{rt}->{ln});                                    local_name => $ElementDef->{rt}->{ln});
1726          } else {          } else {
1727            $current->append_text ($$source, $-[0], $+[0]-$-[0]);            $current->append_text (substr ($$source, $-[0], $+[0]-$-[0]-1));
1728              pos ($$source)--;
1729          }          }
1730        } elsif ($$source =~ /\G'''?/gc) {        } elsif ($$source =~ /\G'''?/gc) {
1731          my $type = $+[0] - $-[0] == 3 ? 'strong' : 'em';          my $type = $+[0] - $-[0] == 3 ? 'strong' : 'em';
# Line 826  Function: Line 1737  Function:
1737                                    namespace_uri => $NS_XHTML2,                                    namespace_uri => $NS_XHTML2,
1738                                    local_name => $type);                                    local_name => $type);
1739          }          }
1740        } elsif ($$source =~ /\G<([0-9A-Za-z_+.%-]+):($Reg_URI_Opaque)>/gc) {        } elsif ($$source =~ /\G<([0-9A-Za-z_+.%-]+):($Reg_URI_Opaque)>/gco) {
1741          my ($scheme, $data) = ($1, $2);          my ($scheme, $data) = ($1, $2);
1742          my $link = $current->append_new_node          my $link = $current->append_new_node
1743                                   (type => '#element',                                   (type => '#element',
1744                                    namespace_uri => $NS_SW09,                                    namespace_uri => $NS_SW09,
1745                                    local_name => 'anchor-external');                                    local_name => 'anchor-external');
1746          if (substr ($scheme, 0, 1) =~ /[A-Z]/) {          if (substr ($scheme, 0, 1) =~ /[A-Z]/) {
1747            $link->set_attribute (scheme => $scheme);            $link->set_attribute (resScheme => $scheme,
1748            $link->set_attribute (data => $data);                                  namespace_uri => $NS_SW09);
1749              $link->set_attribute (resParameter => $data,
1750                                    namespace_uri => $NS_SW09);
1751          } else { # URI Reference          } else { # URI Reference
1752            $link->set_attribute (href => $scheme.':'.$data);            $link->set_attribute (resScheme => 'URI',
1753                                    namespace_uri => $NS_SW09);
1754              $link->set_attribute (resParameter => $scheme.':'.$data,
1755                                    namespace_uri => $NS_SW09);
1756          }          }
1757            $link->append_text ($scheme.':'.$data);
1758        } elsif ($$source =~ /\G__&&/gc) {        } elsif ($$source =~ /\G__&&/gc) {
1759          if ($$source =~ /\G([^&]+)&&__/gc) {          if ($$source =~ /\G([^&]+)&&__/gc) {
1760            $current->append_new_node            $current->append_new_node
# Line 849  Function: Line 1766  Function:
1766            $current->append_text ('__&&');            $current->append_text ('__&&');
1767          }          }
1768        } elsif ($$source =~ /\G((?>        } elsif ($$source =~ /\G((?>
1769                                    [^'\[\]<>]+                                    [^'\[\]<>_]+
1770                                  | '   (?!')                                  | '   (?!')
1771                                  | \[  (?![A-Z\[])                                  | \[  (?!\[|[A-Z]+(?>\([^()\\]*
1772                                                           (?>[^()\\]+|\\.)*\))?\[)
1773                                  | \]  (?! \]                                  | \]  (?! \]
1774                                          | >>[0-9]+\]                                          | >>[0-9]+\]
1775                                          | <[0-9A-Za-z_+.%-]+:$Reg_URI_Opaque>\]                                          | <[0-9A-Za-z_+.%-]+:$Reg_URI_Opaque>\]
# Line 865  Function: Line 1783  Function:
1783          for ($current->append_new_node (type => '#element',          for ($current->append_new_node (type => '#element',
1784                                          namespace_uri => $NS_SW09,                                          namespace_uri => $NS_SW09,
1785                                          local_name => 'anchor-internal')) {                                          local_name => 'anchor-internal')) {
1786            $_->set_attribute (anchor => 0+$1);            $_->set_attribute (anchor => 0+$1,
1787                                 namespace_uri => $NS_SW09);
1788            $_->append_text ('>>'.$1);            $_->append_text ('>>'.$1);
1789          }          }
1790        } else {        } else {
1791          die "Implementation buggy: ", substr ($$source, pos $$source);          CORE::die "Implementation buggy: ", substr ($$source, pos $$source);
1792        }        }
1793      }      }
1794    
 Function:  
   @Name: to_html  
   @Description:  
     @@@:Converting SuikaWiki/0.9 to Hypertext Markup Language  
     @@lang:en  
   @Main:  
             my (undef, $txt, %option) = @_;  
               
             ## Load constants  
 #           my %const;  
 #           if ($option{magic} =~ /import="([^"]+)"/) {  
 #             for (split /\s*,\s*/, $1) {  
 #               my $wp = $main::database{$_};  
 #               if ($wp =~ m!^\#\?SuikaWikiConst/(?:0.9|1.0)!) {  
 #                 wiki::suikawikiconst::to_hash ($wp => \%const);  
 #               }  
 #             }  
 #           }  
               
 #           $txt =~ s{__&&([^&]+)&&__}{defined $const{$1}?$const{$1}:qq(__&&$1&&__)}ge;  
   
             my (@txt) = split(/\n/, $txt);  
             my (@saved, @result);  
             my $p = $option{-parent}  
                  || Message::Markup::XML::Node->new (type => '#fragment');  
             my $current = $p;  
             my %depth;  
             my $exit_p = sub {  
                   my $current = shift;  
                   if ($current->local_name eq 'p') {  
                     $current = $current->parent_node;  
                   }  
                   $current;  
             };  
             my $cut_anchor = sub {  
               my ($current, $content) = @_;  
                   if ($content =~ s/^\s*\[([0-9]+)\]\s+//) {  
                     my $num = 0 + $1;  
                     for my $A ($current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'a')) {  
                       $A->set_attribute (id => 'anchor-' . $num);  
                       $A->set_attribute (name => 'anchor-' . $num);  
                       $A->set_attribute (class => 'anchor');  
                       $A->append_text ('[' . $num . ']');  
                     }  
                     $current->append_text (' ');  
                   }  
               $content;  
             };  
             my $back_to_section = sub {  
               my $current = shift;  
               while ($current->node_type ne '#fragment') {  
                 if ({ins=>1,del=>1,blockquote=>1}->{$current->local_name}) {  
                   return $current;  
                 }  
                 $current = $current->parent_node;  
               }  
               return $current;  
             };  
               
             foreach (@txt) {  
                 chomp;  
                 if ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\*\*\*\*\*([^\x0D\x0A]*)/) {  
                     $current = &$back_to_section ($current);  
                     for my $H ($current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h6')) {  
                       $H->append_node (_inline_xml ($1, %option));  
                     }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\*\*\*\*([^\x0D\x0A]*)/) {  
                     $current = &$back_to_section ($current);  
                     for my $H ($current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h5')) {  
                       $H->append_node (_inline_xml ($1, %option));  
                     }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\*\*\*([^\x0D\x0A]*)/) {  
                     $current = &$back_to_section ($current);  
                     for my $H ($current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h4')) {  
                       $H->append_node (_inline_xml ($1, %option));  
                     }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\*\*([^\x0D\x0A]*)/) {  
                     $current = &$back_to_section ($current);  
                     for my $H ($current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h3')) {  
                       $H->append_node (_inline_xml ($1, %option));  
                     }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\*([^\x0D\x0A]*)/) {  
                     $current = &$back_to_section ($current);  
                     for my $H ($current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'h2')) {  
                       $H->append_node (_inline_xml ($1, %option));  
                     }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^([-=]{1,6})(.*)/) {  
                   my ($depth, $content, $type) = (length ($1), $2, (substr ($1, -1) eq '-' ? 'ul' : 'ol'));  
                   $current = &$exit_p ($current);  
                   if ($current->local_name eq 'li') {  
                     if ($depth{list} == $depth && $depth{list_type} eq $type) {  
                       $current = $current->parent_node;  
                     } elsif ($depth <= $depth{list}) {  
                       for (1..($depth{list} - $depth)*2) {  
                         ($depth{list} = 1, last) unless ref $current->parent_node;  
                         ($depth{list} = 1, last) unless {li=>1,ul=>1,ol=>1}->{$current->local_name};  
                         $current = $current->parent_node;  
                         $depth{list} -= 0.5;  
                       }  
                       $current = $current->parent_node;  
                       if ($type ne $current->local_name) {  
                         $current = $current->parent_node->append_new_node (namespace_uri => $NS_XHTML1, local_name => $type);  
                         $current->parent_node->append_text ("\n");  
                       }  
                     } else {    # $depth{list} < $depth  
                       $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => $type);  
                       $current->parent_node->append_text ("\n");  
                       $depth{list}++;  
                     }  
                   } else {  
                     $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => $type);  
                     $current->parent_node->append_text ("\n\n");  
                     $depth{list} = 1;  
                   }  
                   $depth{list_type} = $type;  
                   $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'li');  
                   $current->parent_node->append_text ("\n");  
                   $content = &$cut_anchor ($current, $content);  
                   $current->append_node (_inline_xml ($content, %option));  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^:([^:]+):(.*)/) {  
                   $current = &$exit_p ($current);  
                   if ($current->local_name eq 'dd') {  
                     $current = $current->parent_node;  
                   } else {  
                     $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'dl');  
                   }  
                   $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'dt')  
                           ->append_node (_inline_xml ($1, %option));  
                   $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'dd');  
                   $current->append_node (_inline_xml ($2, %option));  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^(?!>>[0-9])(>{1,5})(.*)/) {  
                   my ($depth, $content) = (length $1, $2);  
                   $current = &$exit_p ($current);  
                   if ($depth == $depth{bq}) {  
                     #  
                   } elsif ($depth{bq} < $depth) {  
                     $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'blockquote');  
                     $depth{bq}++;  
                   } else {      # $depth < $depth{bq}  
                     for (1..($depth{bq}-$depth)) {  
                       last if $current->node_type eq '#fragment';  
                       $current = &$back_to_section ($current->parent_node);  
                     }  
                     $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'blockquote')  
                       unless $current->local_name eq 'blockquote';  
                     $depth{bq} = $depth;  
                   }  
                   if (length $content) {  
                     $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'p');  
                     $current->append_node (_inline_xml ($content, %option));  
                   }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\s*$/) {  
                   $current = &$back_to_section ($current);  
                   while ($current->local_name eq 'blockquote') {  
                     $depth{bq}--;  
                     $current = &$back_to_section ($current->parent_node);  
                   }  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^(\s+.*)$/) {  
                   if ($current->local_name ne 'pre') {  
                     $current = &$exit_p ($current)->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'pre');  
                     #$depth{block_name}->{++$depth{block}} = 'pre';  
                   }  
                   $current->append_node (_inline_xml ($1, %option));  
                 } elsif ($depth{block_name}->{$depth{block}} ne 'PRE' && /^\,(.*?)[\x0D\x0A]*$/) {  
                   $current = &$exit_p ($current);  
                   if ($current->local_name eq 'td') {  
                     $current = $current  
                                ->parent_node    # tr  
                                ->parent_node    # tbody  
                                ->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'tr');  
                   } else {  
                     $current = $current  
                                ->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'table')  
                                ->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'tbody')  
                                ->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'tr');  
                   }  
                   $current->parent_node->append_text ("\n");    # </tr>\n  
                   my $tmp = "$1,";  
                   my @value = map {/^"(.*)"$/ ? scalar($_ = $1, s/""/"/g, $_) : $_} ($tmp =~ /("[^"]*(?:""[^"]*)*"|[^,]*),/g);  
                   my @colspan = map {($_ eq '==') ? 0 : 1} @value;  
                   my ($tr, $td) = ($current, $current);  
                   for (my $i = 0; $i < @value; $i++) {  
                     if ($colspan[$i]) {  
                       while ($i + $colspan[$i] < @value and $value[$i + $colspan[$i]] eq '==') {  
                         $colspan[$i]++;  
                       }  
                       $td = $tr->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'td');  
                       $td->set_attribute (colspan => $colspan[$i]) if $colspan[$i] > 1;  
                       $td->append_node (_inline_xml ($value[$i], %option));  
                     }  
                   }  
                   if ($td->local_name eq 'tr') {        # No <td/> in the <tr/> (error!)  
                     $td = $tr->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'td');  
                   }  
                   $current = $td;  
                 } elsif (/^\[(INS|DEL|PRE)\[\s*$/) {  
                   if ($depth{block_name}->{$depth{block}} ne 'PRE') {  
                     $current = &$exit_p ($current)->append_new_node (namespace_uri => $NS_XHTML1, local_name => lc $1);  
                     $depth{block}++;  
                     $depth{block_name}->{$depth{block}} = $1;  
                   } else {  
                     $current->append_text ($_);  
                   }  
                 } elsif ($depth{block} && /^\]($depth{block_name}->{$depth{block}})\]\s*$/) {  
                   while ($current->node_type ne '#fragment') {  
                     if ($current->local_name eq lc $depth{block_name}->{$depth{block}}) {  
                       $current = $current->parent_node;  
                       $depth{block}--;  
                       last;  
                     }  
                     $current = $current->parent_node;  
                   }  
                 } else {  
                   if ($current->node_type eq '#fragment' || {ins=>1,del=>1}->{$current->local_name}) {  
                     $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'p');  
                     $current->parent_node->append_text ("\n\n");        # <P> is two <BR>s:-)  
                   }  
                   $current->append_node (_inline_xml (&$cut_anchor ($current, $_), %option));  
                 }  
             }  
             $p;  
   
 Function:  
   @Name: _id_and_name_xml  
   @Main:          
           my ($e, $name) = @_;  
           $e->set_attribute (id => $name);  
           if (SuikaWiki::Plugin->user_agent_names =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) {  
             $e->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'a')  
               ->set_attribute (name => $name);  
           }  
   
 Function:  
   @Name: _inline_xml  
   @Main:          
           my ($line, %option) = @_;  
           my $l = Message::Markup::XML::Node->new (type => '#fragment');  
           my $current = $l;  
           $line =~ s{(?:\[([A-Z]+)(?:\(([^)]*)\))?\[|(\[\[#form(?:\([A-Za-z0-9-]+\))?(?::'(?:[^'\\]|\\.)*')+\]\]|\[\[[^]]+\](?:>>[0-9]+)?\])|(\]\])|(\] \[)|(>>[0-9]+|<[A-Za-z0-9%]+:[^>]+>|'''?)|([\[\]'<>]|[^\[\]'<>]+))}{  
             my ($el_name, $attr, $lnk, $etag, $nxt, $misc, $s) = ($1, $2, $3, $4, $5, $6, $7);  
             if ($el_name) {  
               my $edef = {  
                 ABBR    => {html_el => 'abbr', use_class_attr => 1},  
                 CODE    => {html_el => 'code', use_class_attr => 1},  
                 DEL     => {html_el => 'del', use_class_attr => 1},  
                 DFN     => {html_el => 'dfn', use_class_attr => 1},  
                 INS     => {html_el => 'ins', use_class_attr => 1},  
                 KBD     => {html_el => 'kbd', use_class_attr => 1},  
                 RUBY    => {html_el => 'ruby'},  
                 RUBYB   => {html_el => 'ruby', html_class => 'descriptive'},  
                 SAMP    => {html_el => 'samp', use_class_attr => 1},  
                 SUB     => {html_el => 'sub'},  
                 SUP     => {html_el => 'sup'},  
                 VAR     => {html_el => 'var', use_class_attr => 1},  
                 WEAK    => {html_el => 'span', html_class => 'weak'},  
               }->{ $el_name };  
               if ($edef) {  
                 $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => $edef->{html_el});  
                 $current->set_attribute (class => $edef->{html_class}) if $edef->{html_class};  
                 $current->get_attribute ('class', make_new_node => 1)  
                         ->append_text ($attr) if $attr && $edef->{use_class_attr};  
                 if ($edef->{html_el} eq 'ruby') {  
                   $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'rb');  
                 }  
               } else {  
                 $current->append_text ($&);  
               }  
             } elsif ($etag) {  
               if (ref $current->parent_node) {  
                 if ($current->node_type eq '#attribute') {  
                   $current = $current->parent_node;  
                 }  
                 $current = $current->parent_node;  
                 if ($current->local_name eq 'ruby') {  
                   $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'rp', value => ')');  
                   $current = $current->parent_node;  
                 }  
               } else {  
                 $current->append_text (']]');  
               }  
             } elsif ($nxt) {  
               my $c_l_n = $current->local_name;  
               if ($c_l_n eq 'rb') {  
                 for ($current->parent_node) {  
                   $_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'rp', value => '(');  
                   $current = $_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'rt');  
                 }  
               } elsif ($c_l_n eq 'rt') {  
                 for ($current->parent_node) {  
                   $_->append_text (' ');  
                   $current = $_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'rt');  
                 }  
               } elsif ($c_l_n eq 'abbr') {  
                 $current = $current->get_attribute ('title', make_new_node => 1);  
               } else {  
                 $current->append_text ('] [');  
               }  
             } elsif ($lnk) {  
               if ($lnk =~ /\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/) {  
                 $current->append_new_node (type => '#xml', value => scalar SuikaWiki::Plugin::WikiFormCore->_make_custom_form ($1, $2, $3, $4, \%option));  
               } elsif ($lnk =~ /\[\[([^]]+)\](?:>>([0-9]+))?\]/) {  
                 my ($page, $anchor) = ($1, $2);  
                 if (substr ($page, 0, 1) eq '#') {  
                   $current->append_new_node (type => '#xml', value => scalar embedded_to_html ($lnk, $option{page}));  
                 } else {  
                   $current->append_node (SuikaWiki::Plugin->module_package ('WikiLinking')->to_wikipage_in_html ({  
                         label   => SuikaWiki::Plugin->resource ('Link:toWikiPage:SourceLabel'),  
                   } => {  
 #TODO:                  base    => [$option{page}],  
                         page_name_relative      => [split m#//#, $page],  
                         page_anchor_no  => 0+$anchor,  
                   }, {o=>$option{o}}));  
                   #$current->append_new_node (type => '#xml', value => scalar main::make_wikilink ($page, anchor => 0+$anchor, base => $option{page}));  
                 }  
               }  
             } elsif ($misc) {  
               if ($misc =~ />>([0-9]+)/) {  
                 for my $A ($current->append_new_node (local_name => 'a', namespace_uri => $NS_XHTML1)) {  
                   $A->set_attribute (href => '#anchor-' . $1);  
                   $A->set_attribute (class => 'wiki-anchor');  
                   $A->append_text ('>>' . $1);  
                 }  
               } elsif ($misc =~ /<([A-Za-z0-9%]+:[^>]+)>/) {    # BUG: <IW:foo:"<foo>"> doesn't match  
                 $current->append_new_node (type => '#xml', value => scalar main::make_urilink ($1));  
               } elsif ($misc eq q('')) {  
                 if ($current->local_name eq 'em') {  
                   $current = $current->parent_node;  
                 } else {  
                   $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'em');  
                 }  
               } else {  # '''  
                 if ($current->local_name eq 'strong') {  
                   $current = $current->parent_node;  
                 } else {  
                   $current = $current->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'strong');  
                 }  
               }  
             } else {  
               $current->append_text ($s);  
             }  
             '';  
           }ge;  
           return $l;  
   
 Function:  
   @Name: embedded_to_html  
   @Main:          
             my ($embedded, $bPage) = @_;  
             my $CommentIndex = SuikaWiki::Plugin->new_index ('sw09--comment');  
             if ($embedded eq '[[#comment]]' or $embedded eq '[[#rcomment]]') {  
               unless ($main::_EMBEDED) {  
                 my $lastmodified = SuikaWiki::Plugin->get_data (lastmodified => [split m!//!, $bPage]);  
                 return <<"EOD";  
                 <form action="@{[SuikaWiki::Plugin->uri ('wiki')]}" method="post" id="x-comment-@{[$CommentIndex]}" class="comment"><p>  
             <input type="hidden" name="mycmd" value="comment" />  
             <input type="hidden" name="mypage" value="@{[SuikaWiki::Plugin->escape($bPage)]}" />  
             <input type="hidden" name="myLastModified" value="$lastmodified" />  
             <input type="hidden" name="mytouch" value="on" />  
             <input type="hidden" name="comment_index" value="$CommentIndex" />  
         \    @{[SuikaWiki::Plugin->resource('WikiForm:WikiComment:Name=',escape=>1)]}  
             <input type="text" name="myname" value="" size="10" class="comment-name" />  
             <input type="text" name="mymsg" value="" size="30" class="comment-msg" />  
             <input type="submit" value="@{[SuikaWiki::Plugin->resource('WikiForm:Add',escape=>1)]}" title="@{[SuikaWiki::Plugin->resource('WikiForm:AddLong',escape=>1)]}" class="comment-submit" />  
         </p></form>  
   EOD  
              } else {  
                 return <<"EOD";  
         <del><form action="@{[SuikaWiki::Plugin->uri ('wiki')]}" method="get">  
             <input type="hidden" name="mycmd" value="default" />  
             <input type="hidden" name="mypage" value="@{[SuikaWiki::Plugin->escape($bPage)]}" />  
          \   @{[SuikaWiki::Plugin->resource('WikiForm:WikiComment:Name=',escape=>1)]}  
             <input type="text" name="myname" value="" size="10" disabled="disabled" />  
             <input type="text" name="mymsg" value="" size="60" disabled="disabled" />  
         </form></del>  
         EOD  
             }  
           } elsif ($embedded =~ /^\[\[\#embed:(.+)\]\]$/) {  
             my ($name, $r) = ($1, '');  
             if ($name =~ s/^IMG://) {  
               my ($magic, $content) = SuikaWiki::Plugin->magic_and_content ($main::database{$name});  
               $r = &main::convert_format ($content, $magic => 'HTML_fragment', page => $name, magic => $magic, -error_no_return => 1);  
               if (defined $r) {  
                 return $r;  
               } else {  
                 return '<span class="error-embed-image">'.SuikaWiki::Plugin->resource ('Embed:ImageNotSupported', escape=>1).'</span>';  
               }  
             } else {  
               if ($main::_EMBEDED != 1) {  
                 my ($cf, $content) = SuikaWiki::Plugin->magic_and_content ($main::database{$name});  
                 $cf ||= '#?SuikaWiki/0.9';  
                 if ($cf =~ m!^#\?SuikaWiki/0.9(?:$|\s)!) {  
                   $main::_EMBEDED = 1;  
                   $r = &text_to_html ($content, magic => $cf, page => $name);  
                   $main::_EMBEDED = 0;  
                 } elsif (length $content) {  
                   $r = "<pre>@{[SuikWiki::Plugin->escape ($content)]}</pre>";  
                 } else {  
                   $r = &text_to_html ("[INS[\n[[$name]]: @{[SuikaWiki::Plugin->resource('Embed:PageNotFound')]}\n]INS]\n", magic => '#?SuikaWiki/0.9');  
                 }  
               } else {  ## nested #EMBED  
                 $r = &text_to_html ("[INS[\n[[$name]]: @{[SuikaWiki::Plugin->resource('Embed:Nested',escape=>1)]}\n]INS]\n", magic => '#?SuikaWiki/0.9');  
               }  
               return qq(<blockquote title="@{[SuikaWiki::Plugin->escape($name)]}" class="wiki-embed">$r<div class="cite-note">��<cite><a href="@{[SuikaWiki::Plugin->uri ('wiki') . SuikaWiki::Plugin->encode($name)]}" class="wiki">@{[SuikaWiki::Plugin->escape($name)]}</a></cite>��</div></blockquote>);  
             }  
           } else {  
             return $embedded;  
           }  
   
1795  FormattingRule:  FormattingRule:
1796    @Category[list]: page-link    @Category[list]:
1797        page-link
1798        link-to-resource
1799    @Name: sw09--link-anchor-content    @Name: sw09--link-anchor-content
1800    @Description:    @Description:
1801      @@@:      @@@:
# Line 1292  FormattingRule: Line 1805  FormattingRule:
1805      if ($o->{var}->{sw09__anchor_content}) {      if ($o->{var}->{sw09__anchor_content}) {
1806        $o->{var}->{sw09__anchor_content}->($p->{-parent});        $o->{var}->{sw09__anchor_content}->($p->{-parent});
1807      } else {      } else {
1808        $p->{-parent}->append_node (SuikaWiki::Plugin->resource        $WIKIRESOURCE->append_tree
1809                        ('Link:SuikaWiki/0.9:link-anchor-content:InvalidContext'),              (name => 'Link:SuikaWiki/0.9:link-anchor-content:InvalidContext',
1810                                    node_or_text => 1);               param => $o,
1811                 -parent => $p->{-parent},
1812                 wiki => $o->{wiki});
1813      }      }
1814    
1815  Resource:  Resource:
1816    @Link:SuikaWiki/0.9:link-anchor-content:InvalidContext:    @Link:SuikaWiki/0.9:link-anchor-content:InvalidContext:
1817      @@@: %sw09--link-anchor-content; cannot be used in this context.      @@@: %percent;sw09--link-anchor-content; cannot be used in this context.
1818        @@lang:en
1819      @Link:SuikaWiki/0.9:toResource:SourceLabel:
1820        @@@:
1821          %select_link_resource_scheme (
1822            URI => {<%link-to-it(
1823              label=>{%link-resource-parameters;}p,
1824            );>},
1825            MAIL => {<%link-to-it(
1826              label => {%link-resource-parameters;}p,
1827              description
1828                => {%res (name=>{Link:MailAddress=});<%link-resource-parameters;>}p,
1829            );>},
1830            otherwise => {<%link-to-it(
1831              label => {%sw09--link-anchor-content;}p,
1832              description => {%res (name=>{Link:URIReference=});<%uri-reference;>}p,
1833            );>},
1834          );
1835      @@lang:en      @@lang:en
1836    @Link:SuikaWiki/0.9:toWikiPage:SourceLabel:    @Link:SuikaWiki/0.9:toWikiPage:SourceLabel:
1837      @@@:      @@@:
# Line 1314  Resource: Line 1846  Resource:
1846          );}p,          );}p,
1847          class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,          class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,
1848        );        );
1849      @SuikaWiki/0.9:form:comment:input:
1850          %line (content => {%textarea (id=>msg,size=>20,lines=>3);}p);
1851          %line (content => {
1852            (%text (description => {%res (name => {Form:Description:HumanName});}p,
1853                    id => name, size => 6);
1854             [%text (description =>
1855                       {%res (name => {Form:Description:MailAddress});}p,
1856                     id => mail, size => 5);]
1857             %check (default, id => record-date,
1858                     label => {%res (name => {Form:Label:LogDate});}p,
1859                     description => {%res (name => {Form:Description:LogDate});}p);)
1860             %submit (label => {%res (name => {Form:Label:Add});}p,
1861                      description => {%res (name => {Form:Description:Add});}p);
1862             %we--update-lastmodified-datetime;
1863          }p);
1864      @SuikaWiki/0.9:form:comment:template:
1865        %n
1866       ;[%index;]%n
1867       ;%text(source=>msg);%n;(%name;%text(source=>mail,prefix=>" [",suffix=>"]");%iif(source=>record-date,true=>" [WEAK[%date;]]");)%n;
1868      @SuikaWiki/0.9:form:comment:option:
1869        %require (msg);
1870      @SuikaWiki/0.9:form:footannotate:input:
1871          %line (content => {%textarea (id=>msg,size=>20,lines=>3);}p);
1872          %line (content => {
1873            (%text (description => {%res (name => {Form:Description:HumanName});}p,
1874                    id => name, size => 6);
1875             [%text (description =>
1876                       {%res (name => {Form:Description:MailAddress});}p,
1877                     id => mail, size => 5);]
1878             %check (default, id => record-date,
1879                     label => {%res (name => {Form:Label:LogDate});}p,
1880                     description => {%res (name => {Form:Description:LogDate});}p);)
1881             %submit (label => {%res (name => {Form:Label:Add});}p,
1882                      description => {%res (name => {Form:Description:Add});}p);
1883             %we--update-lastmodified-datetime;
1884          }p);
1885      @SuikaWiki/0.9:form:footannotate:template:
1886         %n
1887        ;[%index;]%n
1888        ;%text(source=>msg);%n
1889        ;(%name;%text(source=>mail,prefix=>" [",suffix=>"]");%iif(source=>record-date,true=>" [WEAK[%date;]]");)%n;
1890      @SuikaWiki/0.9:form:footannotate:option:
1891        %require (msg);
1892    
1893    Error:
1894      @Name: text_parse
1895      @Definition:
1896        @@INLINE_NO_CLOSE_TAG:
1897          @@@description:
1898            Close tag of element "%t (name => element_type);" not found.
1899          @@@level: non-fatal
1900        @@BLOCK_NO_CLOSE_TAG:
1901          @@@description:
1902            Close tag of element "%t (name => element_type);" not found.
1903          @@@level: non-fatal
1904        @@INVALID_FORM:
1905          @@@description:
1906            Invalid syntax of WikiForm
1907          @@@level: non-fatal
1908        
1909    Error:
1910      @Name: xml_to_text
1911      @IsA[list]:
1912        ::SuikaWiki::Format::
1913      @Definition:
1914        @@

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24