/[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.11 by wakaba, Mon Mar 29 03:21:24 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]: w@suika.fam.cx      @@Mail[list]: w@suika.fam.cx
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          $WIKIFORMCORE->set_option ($opt{option} => $opt{o}) if $opt{option};
200    
201          my @missing;
202          for (keys %{$opt{o}->{form}->{require}->{id}}) {
203            unless (length $opt{o}->{wiki}->{input}->parameter
204                         ($WIKIFORMCORE->control_id ($opt{o}, local_id => $_,
205                                                     local_id_prefix => 'wikiform__')
206                                       ->{local_id})) {
207              push @missing, $_;
208            }
209          }
210          if (@missing) {
211            return [{
212              type => 'required_param_missing',
213              missing_id => \@missing,
214            }];
215          }
216          
217          ## Replace Output Template
218          my $result;
219          if ($ref eq 'form') {
220            $opt{template} ||= $form->get_attribute_value
221                                        ('template', default => '');
222          } elsif ($ref eq 'comment') {
223            $opt{template} ||= $WIKIRESOURCE->get
224                                 (name => 'SuikaWiki/0.9:form:comment:template',
225                                  o => $opt{o}, wiki => $opt{o}->{wiki});
226          } elsif ($ref eq '#footannotate') {
227            $opt{template} ||= $WIKIRESOURCE->get
228                                 (name => 'SuikaWiki/0.9:form:footannotate:template',
229                                  o => $opt{o}, wiki => $opt{o}->{wiki});
230          }
231          try {
232            $result = SuikaWiki::Plugin->text_formatter ('form_template')
233                             ->replace ($opt{template}, param => $opt{o});
234          } catch Message::Util::Formatter::error with {
235            my $err = shift;
236            SuikaWiki::Plugin->module_package ('Error')
237                             ->reporting_formatting_template_error
238                                 ($err, $err->{option}->{param}->{wiki});
239    ##TODO:
240            throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
241          };      
242    
243          ## Insert
244          if (length $result) {
245            if ($ref eq '#footannotate') {
246              my $parent;
247              for (@{$xml->child_nodes}) {
248                if ($_->node_type eq '#element' and
249                    $_->local_name eq 'document') {
250                  for (@{$_->child_nodes}) {
251                    if ($_->node_type eq '#element' and
252                        $_->local_name eq 'body') {
253                      $parent = $_;
254                      last;
255                    }
256                  }
257                }
258              }
259              CORE::die "Buggy implementation: no body element".$xml
260                        unless ref $parent;
261              
262              $parent->append_new_node (type => '#element',
263                                        namespace_uri => $NS_SW09,
264                                        local_name => 'text')
265                     ->append_text ($result);
266            } else {
267              my $parent = $form->parent_node;
268              CORE::die "Byggy implementation: No parent of form" unless ref $parent;
269              my $children = $parent->child_nodes;
270              
271              $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
272              $parent->append_new_node (type => '#element',
273                                        namespace_uri => $NS_SW09,
274                                        local_name => 'text')
275                     ->append_text ($result);
276              my $node = pop @{$children};
277              my $form_str = overload::StrVal ($form);
278              my $i = 0;
279              for (@{$children}) {
280                last if overload::StrVal ($_) eq $form_str;
281                $i++;
282              }
283              if ($opt{o}->{form}->{output}->{reverse}) {
284                splice @{$children}, $i + 1, 0, $node;
285              } else {
286                splice @{$children}, $i, 0, $node;
287              }
288            }
289          } else {
290    ## TODO:
291          }
292    
293          ## XML format -> Text format
294          my $text = __FUNCPACK__->xml_to_text ($xml, {%opt});
295    
296          my %fragment = (fragment => $opt{o}->{form}->{output}->{id}
297                                || 'wikiform-'.$opt{o}->{form}->{output}->{index});
298          if (not $opt{o}->{form}->{output}->{reverse} and
299              $opt{o}->{var}->{sw09__anchor_index}) {
300            %fragment = (anchor_no => $opt{o}->{var}->{sw09__anchor_index});
301          }
302    
303          my $action = [
304            {
305              type => 'write',
306              content => $text,
307              update_lastmodified => time,
308            },
309            {
310              type => 'ok',
311              %fragment,
312            },
313          ];
314    
315      @HeadSummary:
316        @@Main:
317          my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => \%opt,
318                                                wiki => $self->{wiki});
319          return $xml->inner_text;
320    
321    FormattingRule:
322      @Category[list]:form-template
323      @Name: index
324      @Description:
325        @@@: Next anchor index number
326        @@lang:en
327      @After:
328        if ($o->{var}->{sw09__anchor_index}) {
329          ++$o->{var}->{sw09__anchor_index};
330        } else {
331          $o->{var}->{sw09__anchor_index}
332            = 1 + __FUNCPACK__->get_last_anchor_index
333                                  ($o->{var}->{sw09__document_tree});
334        }
335        $p->{-result} .= $o->{var}->{sw09__anchor_index};
336    
337    Function:
338      @Name: get_last_anchor_index
339      @Main:
340          my (undef, $xml) = @_;
341          my $anchor = 0;
342          my $get_anchor_no;
343          $get_anchor_no = sub {
344            my $node = shift;
345            for my $child (@{$node->child_nodes}) {
346              my $nt = $child->node_type;
347              if ($nt eq '#element') {
348                if ($child->namespace_uri => $NS_SW09 and
349                    $child->local_name eq 'anchor-end') {
350                  my $a = $child->get_attribute_value ('anchor', default => 0,
351                                                       namespace_uri => $NS_SW09);
352                  $anchor = 0+$a if $anchor < 0+$a;
353                } else {
354                  $get_anchor_no->($child);
355                }
356              } elsif ($nt eq '#document' or $nt eq '#fragment') {
357                $get_anchor_no->($child);
358              }
359            }
360          };
361          $get_anchor_no->($xml);
362          $anchor;
363    
364    
365    Function:
366      @Name: get_xml_tree
367      @Main:
368        my (undef, %opt) = @_;
369        if ($opt{opt}->{page}) {
370      ## TODO:
371          unless ($__FUNCPACK__::DBLoaded) {
372            $opt{wiki}->{db}->_set_prop_db (sw09__xml_tree => {-db_open => sub {
373              require SuikaWiki::DB::Hash;
374              new SuikaWiki::DB::Hash;
375            }});
376            $__FUNCPACK__::DBLoaded++;
377          }
378        
379          my $xml = new Message::Markup::XML::Node type => '#fragment';
380          __FUNCPACK__->text_to_xml (${$opt{text}}, {%{$opt{opt}}, -parent => $xml});
381    
382          $opt{wiki}->{db}->set (sw09__xml_tree => $opt{opt}->{page} => $xml);
383          $xml;
384        } else {
385          my $xml = new Message::Markup::XML::Node type => '#fragment';
386          __FUNCPACK__->text_to_xml (${$opt{text}}, {%{$opt{opt}}, -parent => $xml});
387          $xml;
388        }
389    
390    Function:
391      @Name: sw09_to_xhtml1
392      @Main:
393        my (undef, %opt) = @_;
394    
395        my ($apply_template, $apply_template_children);        my ($apply_template, $apply_template_children);
396        $apply_template_children = sub {        $apply_template_children = sub {
397          my ($parent, $result) = @_;          for (@{$_[0]->child_nodes}) {
398          for (@{$parent->child_nodes}) {            $apply_template->($_ => $_[1]) unless $_->node_type eq '#attribute';
           $apply_template->($_ => $result) unless $_->node_type eq '#attribute';  
399          }          }
400        };        };
401        $apply_template = sub {        $apply_template = sub {
# Line 113  Format: Line 411  Format:
411            my $class = $source->get_attribute_value ('class', default => '');            my $class = $source->get_attribute_value ('class', default => '');
412            $node->set_attribute (class => $class) if $class;            $node->set_attribute (class => $class) if $class;
413            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
414          } elsif ({qw/ins 1 del 1/}->{$ln}) {          } elsif ({qw/ins 1 del 1 insert 1 delete 1/}->{$ln}) {
415            my $node = $result->append_new_node            my $node = $result->append_new_node
416                                  (type => '#element',                                  (type => '#element',
417                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
418                                   local_name => $ln);                                   local_name => {qw/ins ins insert ins
419                                                       delete del del del/}->{$ln});
420            my $class = $source->get_attribute_value ('class', default => '');            my $class = $source->get_attribute_value ('class', default => '');
421            $node->set_attribute (class => $class) if $class;            $node->set_attribute (class => $class) if $class;
422            ## TODO: cite            ## TODO: cite
# Line 134  Format: Line 433  Format:
433            } elsif ($ln eq 'pre') {            } elsif ($ln eq 'pre') {
434              $node->set_attribute (space => 'preserve',              $node->set_attribute (space => 'preserve',
435                                    namespace_uri => NS_xml_URI);                                    namespace_uri => NS_xml_URI);
436                my $class = $source->get_attribute_value ('class', default => '');
437                $node->set_attribute (class => $class) if length $class;
438            }            }
439            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
440          } elsif ($ln eq 'anchor') {          } elsif ($ln eq 'anchor') {
441            local $opt->{o}->{var}->{sw09__anchor_content} = sub {            local $opt{o}->{var}->{sw09__anchor_content} = sub {
442              $apply_template_children->($source => shift);              $apply_template_children->($source => shift);
443            };            };
444            SuikaWiki::Plugin->module_package ('WikiLinking')            SuikaWiki::Plugin->module_package ('WikiLinking')
445                             ->to_wikipage_in_html ({                             ->to_wikipage_in_html ({
446              label       => SuikaWiki::Plugin->resource              label => $WIKIRESOURCE->get_text
447                               ('Link:SuikaWiki/0.9:toWikiPage:SourceLabel'),                                   (name =>
448                                        'Link:SuikaWiki/0.9:toWikiPage:SourceLabel',
449                                      param => $opt{o},
450                                      wiki => $opt{o}->{wiki}),
451            } => {            } => {
452      ## TODO:              base                => $opt{o}->{wiki}->{var}->{page},
453              page_name_relative  => [split m#//#, $source->inner_text],              page_name_relative  => $opt{o}->{wiki}->name ($source->inner_text),
454              page_anchor_no      => $source->get_attribute_value ('anchor'),              page_anchor_no      => $source->get_attribute_value
455                                         ('anchor',
456                                          namespace_uri => $NS_SW09),
457            }, {            }, {
458              o => $opt->{o},              o => $opt{o},
459              parent => $result,              parent => $result,
460            });            });
461          } elsif ($ln eq 'p') {          } elsif ($ln eq 'p') {
# Line 159  Format: Line 465  Format:
465                                                     local_name => 'p'));                                                     local_name => 'p'));
466          } elsif ($ln eq 'h') {          } elsif ($ln eq 'h') {
467            my $node;            my $node;
468            if ($opt->{o}->{var}->{ws__section_depth} > 6) {            if ($opt{o}->{var}->{ws__section_depth} > 6) {
469              $node = $result->append_new_node              $node = $result->append_new_node
470                                  (type => '#element',                                  (type => '#element',
471                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
472                                   local_name => 'div');                                   local_name => 'div');
473              $node->set_attribute (class => 'heading h'.$opt->{o}->{var}              $node->set_attribute (class => 'heading h'.$opt{o}->{var}
474                                                     ->{ws__section_depth});                                                     ->{ws__section_depth});
475            } else {            } else {
476              $node = $result->append_new_node              $node = $result->append_new_node
477                                  (type => '#element',                                  (type => '#element',
478                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
479                                   local_name => 'h'.$opt->{o}->{var}                                   local_name => 'h'.$opt{o}->{var}
480                                                         ->{ws__section_depth});                                                         ->{ws__section_depth});
481            }            }
482            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
483              $WIKISTRUCT->set_section_id ($result, undef, $opt{o}->{wiki},
484                                                 title => $source->inner_text);
485          } elsif ($ln eq 'ruby' or $ln eq 'rubyb') {          } elsif ($ln eq 'ruby' or $ln eq 'rubyb') {
486            my @child;            my @child;
487            for (@{$source->child_nodes}) {            for (@{$source->child_nodes}) {
# Line 258  Format: Line 566  Format:
566                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
567                                   local_name => 'div');                                   local_name => 'div');
568            $node->set_attribute (class => $ln);            $node->set_attribute (class => $ln);
569            local $opt->{o}->{var}->{ws__section_depth}            local $opt{o}->{var}->{ws__section_depth}
570                = $opt->{o}->{var}->{ws__section_depth} + 1;                = $opt{o}->{var}->{ws__section_depth} + 1;
571            $apply_template_children->($source => $node);            $apply_template_children->($source => $node);
572          } elsif ($ln eq 'anchor-end') {          } elsif ($ln eq 'anchor-end') {
573            my $node = $result->append_new_node            my $node = $result->append_new_node
# Line 267  Format: Line 575  Format:
575                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
576                                   local_name => 'a');                                   local_name => 'a');
577            $node->set_attribute (id => 'anchor-'.$source->get_attribute_value            $node->set_attribute (id => 'anchor-'.$source->get_attribute_value
578                                                    ('anchor', default => '0'));                                                    ('anchor', default => '0',
579                                                       namespace_uri => $NS_SW09));
580              $node->set_attribute (name => 'anchor-'.$source->get_attribute_value
581                                                      ('anchor', default => '0',
582                                                       namespace_uri => $NS_SW09))
583                if $opt{o}->{wiki}->{var}->{client}->{downgrade}->{html_no_id};
584            $node->append_text ($source->inner_text);            $node->append_text ($source->inner_text);
585          } elsif ($ln eq 'anchor-internal') {          } elsif ($ln eq 'anchor-internal') {
586            my $node = $result->append_new_node            my $node = $result->append_new_node
# Line 275  Format: Line 588  Format:
588                                   namespace_uri => $NS_XHTML1,                                   namespace_uri => $NS_XHTML1,
589                                   local_name => 'a');                                   local_name => 'a');
590            $node->set_attribute (href => '#anchor-'.$source->get_attribute_value            $node->set_attribute (href => '#anchor-'.$source->get_attribute_value
591                                                       ('anchor', default => '0'));                                                       ('anchor',
592                                       namespace_uri => $NS_SW09, default => '0'));
593            $node->set_attribute (class => 'wiki-anchor');            $node->set_attribute (class => 'wiki-anchor');
594            $node->append_text ($source->inner_text);            $node->append_text ($source->inner_text);
595            } elsif ($ln eq 'anchor-external') {
596              local $opt{o}->{var}->{sw09__anchor_content} = sub {
597                $apply_template_children->($source => shift);
598              };
599              $WIKILINKING
600                    ->to_resource_in_html (
601                        {
602                         label => $WIKIRESOURCE
603                                    ->get_text (name =>
604                                       'Link:SuikaWiki/0.9:toResource:SourceLabel',
605                                       param => $opt{o},
606                                       wiki => $opt{o}->{wiki}),
607                        }, {
608                          resource_scheme =>
609                            $source->get_attribute_value ('resScheme',
610                                                          namespace_uri => $NS_SW09,
611                                                          default => 'URI'),
612                          resource_parameter =>
613                            $source->get_attribute_value ('resParameter',
614                                                          namespace_uri => $NS_SW09,
615                                                          default => ''),
616                        }, {
617                         o => $opt{o},
618                         parent => $result,
619                        });
620            } elsif ($ln eq 'form') {
621              my $ref = $source->get_attribute_value ('ref', default => 'form');
622              if ($ref eq 'form') {
623                $WIKIFORMCORE->make_content_form_in_html
624                                     ($result,
625                                      $source->get_attribute_value
626                                                        ('input', default => ''),
627                                      option => $source->get_attribute_value
628                                                           ('option'),
629                                      name => $source->get_attribute_value ('id'),
630                                      o => $opt{o},
631                                      wiki => $opt{o}->{wiki},
632                                      output => {
633                                        page => $opt{page},
634                                      });
635              } elsif ($ref eq 'comment') {
636                $WIKIFORMCORE->make_content_form_in_html
637                                     ($result,
638                                      $WIKIRESOURCE->get
639                                        (name => 'SuikaWiki/0.9:form:comment:input',
640                                         o => $opt{o}, wiki => $opt{o}->{wiki}),
641                                      option => $WIKIRESOURCE->get
642                                        (name => 'SuikaWiki/0.9:form:comment:option',
643                                         o => $opt{o}, wiki => $opt{o}->{wiki}),
644                                      name => $source->get_attribute_value ('id'),
645                                      o => $opt{o},
646                                      wiki => $opt{o}->{wiki},
647                                      output => {
648                                        page => $opt{page},
649                                      });
650              } else {
651     ## TODO:
652              }
653          } elsif ($ln eq 'dr') {          } elsif ($ln eq 'dr') {
654            $apply_template_children->($source => $result);            $apply_template_children->($source => $result);
655          } elsif ($ln eq 'document') {          } elsif ($ln eq 'document') {
# Line 290  Format: Line 662  Format:
662                                                     namespace_uri => $NS_XHTML1,                                                     namespace_uri => $NS_XHTML1,
663                                                     local_name => 'div');                                                     local_name => 'div');
664            $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;  
665            $apply_template_children->($body => $body_block);            $apply_template_children->($body => $body_block);
666          } else {          } else {
667            my $node = $result->append_new_node            my $node = $result->append_new_node
# Line 314  Format: Line 684  Format:
684          }          }
685        };        };
686                
687        $apply_template_children->($xml => $opt->{-parent});        $apply_template_children->($opt{source} => $opt{parent});
688    
689    
690    @Converter:  Function:
691      @@Type:    @Name: xml_to_text
692        @@@@: application/x-suikawiki+xml    @Main:
693        @@@version: 0.9      my (undef, $src, $opt) = @_;
694      @@Description:  
695        @@@@: Converting SuikaWiki/0.9 text format to XML format  
696        @@@lang: en      my %is_block = (
697      @@Main:        qw/p 1 blockquote 1 pre 1 ul 1 ol 1 dl 1 section 1 h 1
698        __FUNCPACK__->text_to_xml ($source, $opt);           bodytext 1 document 1 head 1 body 1 table 1 text 1 form 1
699             insert 1 delete 1/
700        );
701    
702            my %x2t;
703            %x2t = (
704              anchor => sub {
705                my $source = shift;
706                my $result = '[['
707                          .  $x2t{'#inline'}->($source, no_newline => 1)
708                          .  ']';
709                my $anchor = $source->get_attribute_value
710                                      ('anchor',
711                                       namespace_uri => $NS_SW09,
712                                       default => '');
713                if (length $anchor) {
714                  $result .= '>>'.(0+$anchor);
715                } else {
716                  $anchor = $source->get_attribute_value
717                                      ('resScheme',
718                                       namespace_uri => $NS_SW09);
719                  if ($anchor) {
720                    my $param = $source->get_attribute_value
721                                      ('resParameter',
722                                       namespace_uri => $NS_SW09);
723                    if ($anchor eq 'URI' and $param =~ /^[0-9A-Za-z_+.%-]+:/) {
724                      $result .= '<' . $param . '>';
725                    } else {
726                      $result .= '<' . $anchor . ':' . $param . '>';
727                    }
728                  }
729                }
730                $result . ']';
731              },
732              li => sub {
733                my $source = shift;
734                my $result = ({qw/ul - ol =/}->{$opt->{o}->{var}->{sw09__list_type}}
735                              x $opt->{o}->{var}->{sw09__list_depth})
736                          .  ' ' . $x2t{'#flow'}->($source);
737                $result;
738              },
739              dt => sub {
740                ':' . $x2t{'#inline'}->(return, no_newline => 1) . ':';
741              },
742              h => sub {
743                  ("*" x ($opt->{o}->{var}->{ws__section_depth} - 1))
744                .  " "
745                .  $x2t{'#inline'}->(shift, no_newline => 1);
746              },
747              'anchor-end' => sub {
748                return shift->inner_text;
749              },
750              'anchor-internal' => sub {
751                return shift->inner_text;
752              },
753              'anchor-external' => sub {
754                return '<'.shift->inner_text.'>';
755              },
756              form => sub {
757                my $source = shift;
758                my $ref = $source->get_attribute_value ('ref', default => 'form');
759                my $result = '[[#'.$ref;
760                my $name = $source->get_attribute_value ('id');
761                $name =~ s/([()\\])/\\$1/g;
762                $result .= '(' . $name . ')' if $name;
763                ## General WikiForm
764                if ($ref eq 'form') {
765                  $result .= ":'";
766                  my $input = $source->get_attribute_value ('input', default => '');
767                  $input =~ s/(['\\])/\\$1/g;
768                  $result .= $input . "':'";
769                  my $template = $source->get_attribute_value ('template', default => '');
770                  $template =~ s/(['\\])/\\$1/g;
771                  $result .= $template . "'";
772                  my $option = $source->get_attribute_value ('option');
773                  if ($option) {
774                    $option =~ s/(['\\])/\\$1/g;
775                    $result .= ":'" . $option . "'";
776                  }
777                ## Specific WikiForm
778                } else {
779                  my $param = $source->get_attribute_value ('parameter');
780                  if ($param) {
781                    $result .= ':' . $param;
782                  }
783                }
784                $result .= ']]';
785              },
786              pre => sub {
787                my $source = shift;
788                my $result = '[PRE';
789                my $class = $source->get_attribute_value ('class');
790                if ($class) {
791                  $class =~ s/([\\()])/\\$1/g;
792                  $result .= '(' . $class . ')';
793                }
794                $result .= "[\x0A"
795                        .  $x2t{'#inline'}->($source);
796                $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
797                $result .= "]PRE]\x0A";
798              },
799              insert => sub {
800                my $source = shift;
801                my $result = '[INS';
802                my $class = $source->get_attribute_value ('class');
803                if ($class) {
804                  $class =~ s/([\\()])/\\$1/g;
805                  $result .= '(' . $class . ')';
806                }
807                local $opt->{o}->{var}->{sw09__list_depth} = 0;
808                $result .= "[\x0A"
809                        .  $x2t{'#block'}->($source);
810                $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
811                $result .= "]INS]\x0A";
812              },
813              delete => sub {
814                my $source = shift;
815                my $result = '[DEL';
816                my $class = $source->get_attribute_value ('class');
817                if ($class) {
818                  $class =~ s/([\\()])/\\$1/g;
819                  $result .= '(' . $class . ')';
820                }
821                local $opt->{o}->{var}->{sw09__list_depth} = 0;
822                $result .= "[\x0A"
823                        .  $x2t{'#block'}->($source);
824                $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
825                $result .= "]DEL]\x0A";
826              },
827              document => sub {
828                my $source = shift;
829                my $result = '#?'
830                           . $source->get_attribute_value
831                                        ('Name', namespace_uri => $NS_SW09,
832                                         default => 'SuikaWiki')
833                           . '/'
834                           . $source->get_attribute_value
835                                        ('Version', namespace_uri => $NS_SW09,
836                                         default => '0.9');
837                for (@{$source->child_nodes}) {
838                  $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_)
839                    if $_->node_type eq '#element';
840                }
841                $result;
842              },
843              head => sub {
844                my $source = shift;
845                my $result = '';
846                for (@{$source->child_nodes}) {
847                  if ($_->node_type eq '#element' and
848                      $_->local_name eq 'parameter') {
849                    $result .= ' '.$x2t{parameter}->($_);
850                  }
851                }
852                $result . "\x0A";
853              },
854              parameter => sub {
855                my $source = shift;
856                my $result = $source->get_attribute_value ('name', default => '')
857                          .  '="';
858                my @v;
859                for (@{$source->child_nodes}) {
860                  push @v, $x2t{value}->($_) if $_->node_type eq '#element' and
861                                                $_->local_name eq 'value';
862                }
863                $result .= join ',', @v;
864                $result .  '"';
865              },
866              value => sub {
867                my $value = $x2t{'#inline'}->(shift, no_newline => 1);
868                $value =~ s/(["\\])/\\$1/g;
869                $value =~ tr/\x0A\x0D/ /;
870                $value;
871              },
872              section => sub {
873                local $opt->{o}->{var}->{ws__section_depth}
874                    = $opt->{o}->{var}->{ws__section_depth} + 1;
875                $x2t{'#block'}->(shift);
876              },
877              body => sub {
878                local $opt->{o}->{var}->{ws__section_depth} = 1;
879                $x2t{'#block'}->(shift);
880              },
881              text => sub {
882                my ($source, %opt) = @_;
883                my $result .= '';
884                for (@{$source->child_nodes}) {
885                  if ($_->node_type eq '#text') {
886                    $result .= $_->inner_text;
887                  } elsif ($_->node_type eq '#element') {
888                    $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_);
889                  }
890                }
891                $result;
892              },
893              dr => sub {
894                my $result = $x2t{'#list'}->(shift);
895                if ($result) {
896                  $result . "\x0A";
897                } else {
898                  "::\x0A";
899                }
900              },
901              dt => sub {
902                ':' . $x2t{'#inline'}->(shift, no_newline => 1) . ':';
903              },
904              dd => sub {
905                $x2t{'#inline'}->(shift);
906              },
907              tr => sub {
908                my $result = $x2t{'#list'}->(shift);
909                if ($result) {
910                  substr ($result, 1) . "\x0A";
911                } else {
912                 "',\x0A";
913                }
914              },
915              td => sub {
916                my $source = shift;
917                my $result = $x2t{'#inline'}->($source, no_newline => 1);
918                if ($result =~ /[,"\\]/ or $result =~ /==/) {
919                  $result =~ s/(["\\])/\\$1/g;
920                  $result = '"' . $result . '"';
921                }
922                my $colspan = $source->get_attribute_value ('colspan', default => 1);
923                $result .= ("\t,==" x ($colspan - 1)) if $colspan > 1;
924                "\t," . $result;
925              },
926              em => sub {
927                "''" . $x2t{'#inline'}->($_, no_newline => 1) . "''";
928              },
929              strong => => sub {
930                "'''" . $x2t{'#inline'}->($_, no_newline => 1) . "'''";
931              },
932              rb => sub {
933                $x2t{'#inline'}->(shift, no_newline => 1);
934              },
935              rt => sub {
936                '] [' . $x2t{'#inline'}->(shift, no_newline => 1);
937              },
938              replace => sub {
939                '__&&' . shift->get_attribute_value ('by', default => '') . '&&__';
940              },
941              bodytext => sub {
942                my ($source, %opt) = @_;
943                local $opt->{o}->{var}->{sw09__bq_depth}
944                    = $opt->{o}->{var}->{sw09__bq_depth} + 1;
945                my @result;
946                for (@{$source->child_nodes}) {
947                  if ($_->node_type eq '#element') {
948                    my $ln = $_->local_name;
949                    push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
950                                   $ln];
951                  }
952                }
953                my $result = '';
954                my $prev = '';
955                for (@result) {
956                  my $s = $_->[0];
957                  if ($_->[1] eq 'p') {
958                    $result .= "\x0A" if length $result and
959                                         substr ($result, -1) ne "\x0A";
960                    $result .= ('>' x $opt->{o}->{var}->{sw09__bq_depth}) . ' ';
961                  } elsif ($_->[1] eq 'form' or $_->[1] eq 'replace') {
962                    $result .= "\x0A" if length $result and
963                                         substr ($result, -1) ne "\x0A";
964                    $result .= ('>' x $opt->{o}->{var}->{sw09__bq_depth})."\x0A";
965                  } elsif ($_->[1] eq 'blockquote' or $_->[1] eq 'text') {
966                    $result .= "\x0A" if length $result and
967                                         substr ($result, -1) ne "\x0A";
968                  } else {
969                    unless ($prev eq 'text') {
970                      $result .= "\x0A" if length $result and
971                                           substr ($result, -1) ne "\x0A";
972                    }
973                    $result .= ('>' x $opt->{o}->{var}->{sw09__bq_depth})."\x0A";
974                  }
975                  $result .= $s;
976                  $prev = $_->[1];
977                }
978                $result;
979              },
980              ## Note: This element will be interpreted as a paragraph
981              ##       unless format is SuikaWikiImage/0.9.
982              image => sub {
983                my ($source, %opt) = @_;
984                return "\x0A__IMAGE__\x0A" . $source->inner_text . "\x0A";
985              },
986              '#block' => sub {
987                my ($source, %opt) = @_;
988                my @result;
989                for (@{$source->child_nodes}) {
990                  if ($_->node_type eq '#element') {
991                    my $ln = $_->local_name;
992                    push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
993                                   $ln];
994                  }
995                }
996                my $result = '';
997                my $prev = '';
998                for (@result) {
999                  my $s = $_->[0];
1000                  if ($_->[1] eq 'form') {
1001                    $result .= "\x0A" if length $result and
1002                                         substr ($result, -1) ne "\x0A";
1003                    $result .= "\x0A";
1004                  } elsif ($_->[1] eq 'replace') {
1005                    $result .= "\x0A" if length $result and
1006                                         substr ($result, -1) ne "\x0A";
1007                  } elsif ($_->[1] eq 'text') {
1008                    $result .= "\x0A" if length $result and
1009                                         substr ($result, -1) ne "\x0A";
1010                    $result .= "\x0A" if $prev eq 'p';
1011                  } else {
1012                    if ($prev ne 'text' and $prev ne 'replace') {
1013                      $result .= "\x0A" if length $result and
1014                                           substr ($result, -1) ne "\x0A";
1015                      $result .= "\x0A";
1016                    }
1017                  }
1018                  $result .= $s;
1019                  $prev = $_->[1];
1020                }
1021                $result;
1022              },
1023              '#flow' => sub {
1024                my ($source, %opt) = @_;
1025                my @result;
1026                for (@{$source->child_nodes}) {
1027                  if ($_->node_type eq '#element') {
1028                    my $ln = $_->local_name;
1029                    if ($is_block{$ln}) {
1030                      push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
1031                                     $ln];
1032                    } else {
1033                      if (@result and ($result[$#result]->[1] eq '#inline')) {
1034                        $result[$#result]->[0]
1035                          .= ($x2t{$ln} or $x2t{'#undef'})->($_);
1036                      } else {
1037                        push @result, [($x2t{$ln} or $x2t{'#undef'})->($_),
1038                                       '#inline'];
1039                      }
1040                    }
1041                  } elsif ($_->node_type eq '#text') {
1042                    if (@result and ($result[$#result]->[1] eq '#inline')) {
1043                      $result[$#result]->[0] .= $_->inner_text;
1044                    } else {
1045                      push @result, [$_->inner_text, '#inline'];
1046                    }
1047                  }
1048                }
1049                my $result = '';
1050                my $prev = '';
1051                for (@result) {
1052                  my $s = $_->[0];
1053                  if ($_->[1] eq '#inline') {
1054                    if ($prev ne 'text' and $prev ne 'form' and $prev ne 'replace') {
1055                      $result .= "\x0A" if length $result and
1056                                           substr ($result, -1) ne "\x0A";
1057                    }
1058                    $s =~ s/\x0D\x0A/\x0A/g;
1059                    $s =~ s/\x0D/\x0A/g;
1060                    $s =~ s/\x0A\x0A+/\x0A/g;
1061                    $s =~ s/\x0A/\x20/g if $opt{no_newline};
1062                  } elsif ($_->[1] eq 'form' or $_->[1] eq 'replace') {
1063                    if ($prev ne '#inline') {
1064                      $result .= "\x0A" if length $result and
1065                                           substr ($result, -1) ne "\x0A";
1066                    }
1067                  } elsif ($_->[1] eq 'text') {
1068                    $result .= "\x0A" if length $result and
1069                                         substr ($result, -1) ne "\x0A";
1070                  } else {
1071                    unless ($prev eq 'text') {
1072                      $result .= "\x0A" if length $result and
1073                                           substr ($result, -1) ne "\x0A";
1074                    }
1075                  }
1076                  $result .= $s;
1077                  $prev = $_->[1];
1078                }
1079                $result;
1080              },
1081              '#inline' => sub {
1082                my ($source, %opt) = @_;
1083                my $result .= '';
1084                for (@{$source->child_nodes}) {
1085                  if ($_->node_type eq '#text') {
1086                    $result .= $_->inner_text;
1087                  } elsif ($_->node_type eq '#element') {
1088                    $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_);
1089                  }
1090                }
1091                $result =~ s/\x0D\x0A/\x0A/g;
1092                $result =~ s/\x0D/\x0A/g;
1093                $result =~ s/\x0A\x0A+/\x0A/g;
1094                $result =~ s/\x0A/\x20/g if $opt{no_newline};
1095                $result;
1096              },
1097              '#list' => sub {
1098                my ($source, %opt) = @_;
1099                my $result .= '';
1100                for (@{$source->child_nodes}) {
1101                  if ($_->node_type eq '#element') {
1102                    $result .= ($x2t{$_->local_name} or $x2t{'#undef'})->($_);
1103                  }
1104                }
1105                $result;
1106              },
1107              '#undef' => sub {
1108                my $source = shift;
1109                ## TODO:
1110                "<".$source->namespace_uri.">:".$source->local_name
1111                      .  $x2t{'#inline'}->($source);
1112              },
1113            );
1114            for (qw/blockquote dl tbody table/) {
1115              $x2t{$_} = sub { $x2t{'#list'}->(shift) };
1116            }
1117            for (qw/p dd/) {
1118              $x2t{$_} = sub { $x2t{'#flow'}->(shift) };
1119            }
1120            for my $type (qw/ul ol/) {
1121              $x2t{$type} = sub {
1122                my $source = shift;
1123                local $opt->{o}->{var}->{sw09__list_type} = $type;
1124                local $opt->{o}->{var}->{sw09__list_depth}
1125                    = $opt->{o}->{var}->{sw09__list_depth} + 1;
1126                my @result;
1127                for (@{$source->child_nodes}) {
1128                  push @result, $x2t{$_->local_name}->($_)
1129                    if $_->node_type eq '#element';
1130                }
1131                my $result = '';
1132                for (@result) {
1133                  $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
1134                  $result .= $_;
1135                }
1136                substr ($result, 1);
1137              };
1138            }
1139            for my $type (qw/code samp var dfn kbd sub sup weak q ruby rubyb
1140                             abbr ins del/) {
1141              $x2t{$type} = sub {
1142                my $source = shift;
1143                my $result = '['.uc $type;
1144                my $class = $source->get_attribute_value ('class', default => '');
1145                if ($class) {
1146                  $class =~ s/([()\\])/\\$1/g;
1147                  $result .= '(' . $class . ')';
1148                }
1149                $result .= '['
1150                        .  $x2t{'#inline'}->($source, no_newline => 1)
1151                        .  ']';
1152                my $anchor = $source->get_attribute_value
1153                                      ('anchor',
1154                                       namespace_uri => $NS_SW09,
1155                                       default => '');
1156                if (length $anchor) {
1157                  $result .= '>>'.(0+$anchor);
1158                } else {
1159                  $anchor = $source->get_attribute_value
1160                                      ('resScheme',
1161                                       namespace_uri => $NS_SW09);
1162                  if ($anchor) {
1163                    my $param = $source->get_attribute_value
1164                                      ('resParameter',
1165                                       namespace_uri => $NS_SW09);
1166                    if ($anchor eq 'URI' and $param =~ /^[0-9A-Za-z_+.%-]+:/) {
1167                      $result .= '<' . $param . '>';
1168                    } else {
1169                      $result .= '<' . $anchor . ':' . $param . '>';
1170                    }
1171                  }
1172                }
1173                $result .= ']';
1174                $result;
1175              };
1176            }
1177    
1178        $x2t{'#list'}->($src);
1179    
1180    Function:
1181      @Name: get_nth_element
1182      @Main:
1183        my (undef, $node, $ns => $ln, $n) = @_;
1184        return $n if $n < 1;
1185        if ($node->node_type eq '#element' and
1186            $node->namespace_uri eq $ns and
1187            $node->local_name eq $ln) {
1188          return $node unless --$n;
1189        }
1190        for (@{$node->child_nodes}) {
1191          if ($_->node_type eq '#element') {
1192            if ($_->namespace_uri eq $ns and
1193                $_->local_name eq $ln) {
1194              return $_ unless --$n;
1195            } else {
1196              $n = __FUNCPACK__->get_nth_element ($_, $ns => $ln, $n);
1197              return $n if ref $n;
1198            }
1199          } elsif ($_->node_type eq '#fragment' or $_->node_type eq '#document') {
1200            $n = __FUNCPACK__->get_nth_element ($_, $ns => $ln, $n);
1201            return $n if ref $n;
1202          }
1203        }
1204        return $n;
1205    
1206    Function:
1207      @Name: get_element_by_id
1208      @Main:
1209        my (undef, $node, $id) = @_;
1210        return $node if $node->node_type eq '#element'
1211                    and $node->get_attribute_value ('id', default_value => '')
1212                     eq $id;
1213        for (@{$node->child_nodes}) {
1214          if ({'#element'=>1, '#fragment'=>1, '#document'=>1}->{$_->node_type}) {
1215            my $r = __FUNCPACK__->get_element_by_id ($_, $id);
1216            return $r if $r;
1217          }
1218        }
1219    
1220  Function:  Function:
1221    @Name: text_to_xml    @Name: text_to_xml
# Line 345  Function: Line 1235  Function:
1235      my $head = $root->append_new_node (type => '#element',      my $head = $root->append_new_node (type => '#element',
1236                                         namespace_uri => $NS_XHTML2,                                         namespace_uri => $NS_XHTML2,
1237                                         local_name => 'head');                                         local_name => 'head');
1238      if ($source =~ s#^\#\?SuikaWiki/0\.9\b((?>.*))\s*##) {      $root->append_text ("\x0A");
1239        my $param = $1;      my $body = $root->append_new_node (type => '#element',
1240                                           namespace_uri => $NS_XHTML2,
1241                                           local_name => 'body');
1242        $root->append_text ("\x0A");
1243    
1244        if ($source =~ s#^\#\?(SuikaWiki(?:Image)?)/0\.9\b((?>.*))\s*##) {
1245          my $type = $1;
1246          my $param = $2;
1247          $root->set_attribute (Name => $type, namespace_uri => $NS_SW09);
1248          $root->set_attribute (Version => '0.9', namespace_uri => $NS_SW09);
1249        while ($param =~ /\G\s+([a-z-]+)="((?>[^"\\]*)(?>(?>[^"\\]+|\\.)*))"/g) {        while ($param =~ /\G\s+([a-z-]+)="((?>[^"\\]*)(?>(?>[^"\\]+|\\.)*))"/g) {
1250          my ($name, $value) = ($1, $2);          my ($name, $value) = ($1, $2);
1251          $value =~ s/\\(.)/$1/g;          $value =~ s/\\(.)/$1/g;
1252          for ($head->append_new_node (type => '#element',          for ($head->append_new_node (type => '#element',
1253                                       namespace_uri => $NS_SW09,                                       namespace_uri => $NS_SW09,
1254                                       local_name => 'parmeter')) {                                       local_name => 'parameter')) {
1255            $_->set_attribute (name => $name);            $_->set_attribute (name => $name);
1256            for my $value (split /,/, $value) {            for my $value (split /,/, $value) {
1257              $_->append_new_node (type => '#element',              $_->append_new_node (type => '#element',
# Line 363  Function: Line 1262  Function:
1262          }          }
1263          $head->append_text ("\x0A");          $head->append_text ("\x0A");
1264        }        }
1265          
1266          if ($type eq 'SuikaWikiImage') {
1267            $source =~ s/\x0A__IMAGE__\x0A(.*)$//s;
1268            if (my $image = $1) {
1269              $image =~ s/^\s+//;
1270              $image =~ s/\s+$//;
1271              $root->append_new_node
1272                       (type => '#element',
1273                        namespace_uri => $NS_SW09,
1274                        local_name => 'image')
1275                   ->append_text ($image);
1276              $root->append_text ("\x0A");
1277            }
1278          }
1279      } else {      } else {
1280          $root->set_attribute (Name => 'SuikaWiki', namespace_uri => $NS_SW09);
1281          $root->set_attribute (Version => '0.9', namespace_uri => $NS_SW09);
1282        ## TODO: warn        ## TODO: warn
1283      }      }
     $root->append_text ("\x0A");  
1284            
1285      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);  
1286    
1287  Function:  Function:
1288    @Name:block_text_to_xml    @Name:block_text_to_xml
# Line 382  Function: Line 1293  Function:
1293      @@lang:en      @@lang:en
1294    @Main:    @Main:
1295      my (undef, $source, $current, %opt) = @_;      my (undef, $source, $current, %opt) = @_;
1296      my %depth;      my %depth = %{$opt{depth} || {}};
1297      my $back_to_section = sub {      my $back_to_section = sub {
1298        my $cur_type = $current->local_name;        my $cur_type = $current->local_name;
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 'bodytext'                 or $cur_type eq 'bodytext'
1303                 or $cur_type eq 'ins'                 or $cur_type eq 'insert'
1304                 or $cur_type eq 'del'                 or $cur_type eq 'delete'
1305                   )                   )
1306        ) {        ) {
1307          $current = $current->parent_node;          $current = $current->parent_node;
# Line 403  Function: Line 1314  Function:
1314        while (not (        while (not (
1315                    $cur_type eq 'section'                    $cur_type eq 'section'
1316                 or $cur_type eq 'body'                 or $cur_type eq 'body'
1317                 or $cur_type eq 'ins'                 or $cur_type eq 'insert'
1318                 or $cur_type eq 'del'                 or $cur_type eq 'delete'
1319                   )                   )
1320              ) {              ) {
1321          $current = $current->parent_node;          $current = $current->parent_node;
# Line 465  Function: Line 1376  Function:
1376          $current = $current->append_new_node (type => '#element',          $current = $current->append_new_node (type => '#element',
1377                                                namespace_uri => $NS_XHTML2,                                                namespace_uri => $NS_XHTML2,
1378                                                local_name => 'li');                                                local_name => 'li');
1379          __FUNCPACK__->inline_text_to_xml (\$line => $current);          __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1380        } elsif ($line =~ s/^(\*+)\s*//) {        } elsif ($line =~ s/^(\*+)\s*//) {
1381          my $depth = length $1;          my $depth = length $1;
1382          $back_to_real_section->();          $back_to_real_section->();
# Line 491  Function: Line 1402  Function:
1402          __FUNCPACK__->inline_text_to_xml (\$line =>          __FUNCPACK__->inline_text_to_xml (\$line =>
1403            $current->append_new_node (type => '#element',            $current->append_new_node (type => '#element',
1404                                       namespace_uri => $NS_XHTML2,                                       namespace_uri => $NS_XHTML2,
1405                                       local_name => 'h')                                       local_name => 'h'), %opt,
1406          );          );
1407        } elsif ($line =~ s/^(?!>>[0-9])(>+)\s*//) {        } elsif ($line =~ s/^(?!>>[0-9])(>+)\s*//) {
1408          my $depth = length $1;          my $depth = length $1;
# Line 523  Function: Line 1434  Function:
1434                                   (type => '#element',                                   (type => '#element',
1435                                    namespace_uri => $NS_XHTML2,                                    namespace_uri => $NS_XHTML2,
1436                                    local_name => 'p');                                    local_name => 'p');
1437            __FUNCPACK__->inline_text_to_xml (\$line => $current);            __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1438          }          }
1439        } elsif ($line =~ s/^(?>:\s*)([^:]+?)\s*:\s*//) {        } elsif ($line =~ s/^(?>:\s*)([^:]+?)\s*:\s*//) {
1440          my $parent_type = $current->local_name;          my $parent_type = $current->local_name;
# Line 542  Function: Line 1453  Function:
1453          __FUNCPACK__->inline_text_to_xml (\"$1" =>          __FUNCPACK__->inline_text_to_xml (\"$1" =>
1454            $current->append_new_node (type => '#element',            $current->append_new_node (type => '#element',
1455                                       namespace_uri => $NS_XHTML2,                                       namespace_uri => $NS_XHTML2,
1456                                       local_name => 'dt')                                       local_name => 'dt'), %opt,
1457          );          );
1458          $current->append_text ("\x0A");          $current->append_text ("\x0A");
1459          $current = $current->append_new_node (type => '#element',          $current = $current->append_new_node (type => '#element',
1460                                                namespace_uri => $NS_XHTML2,                                                namespace_uri => $NS_XHTML2,
1461                                                local_name => 'dd');                                                local_name => 'dd');
1462            __FUNCPACK__->inline_text_to_xml (\$line => $current);            __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1463        } elsif ($line =~ /^\[(INS|DEL)(\([^()\\]*\))?\[\s*$/) {        } elsif ($line =~ /^\[(INS|DEL)(?>(\([^()\\]*\))?)\[\s*$/) {
1464          $current->append_text ("\x0A");          $current->append_text ("\x0A");
1465          my $mod = $current->append_new_node (type => '#element',          my $mod = $current->append_new_node
1466                                               namespace_uri => $NS_XHTML1,                                (type => '#element',
1467                                               local_name => lc $1);                                 namespace_uri => $NS_SW09,
1468                                   local_name => {qw/INS insert DEL delete/}->{$1});
1469          $mod->set_attribute (class => $2) if $2;          $mod->set_attribute (class => $2) if $2;
1470          __FUNCPACK__->block_text_to_xml ($source => $mod,          __FUNCPACK__->block_text_to_xml ($source => $mod, %opt,
1471                                           'return_by_'.$1 => 1);                                           'return_by_'.$1 => 1,
1472                                             depth => \%depth);
1473        } elsif ($line =~ /^\](INS|DEL)\]\s*$/) {        } elsif ($line =~ /^\](INS|DEL)\]\s*$/) {
1474          if ($opt{'return_by_'.$1}) {          if ($opt{'return_by_'.$1}) {
1475            return;            return;
1476          } else {          } else {
1477            ## TODO: warn            ## TODO: warn
1478          }          }
1479        } elsif ($line =~ /^\[PRE(\([^()\\]*\))?\[\s*$/) {        } elsif ($line =~ /^\[PRE(?>(?>\(((?>[^()\\]*)(?>(?>[^()\\]+|\\.)*))\))?)\[\s*$/) {
1480          $current->append_text ("\x0A");          $current->append_text ("\x0A");
1481          my $pre = $current->append_new_node (type => '#element',          my $pre = $current->append_new_node (type => '#element',
1482                                               namespace_uri => $NS_XHTML1,                                               namespace_uri => $NS_XHTML1,
# Line 578  Function: Line 1491  Function:
1491              last;              last;
1492            } else {            } else {
1493              $f ? undef $f : $pre->append_text ("\x0A");              $f ? undef $f : $pre->append_text ("\x0A");
1494              __FUNCPACK__->inline_text_to_xml (\$line => $pre);              __FUNCPACK__->inline_text_to_xml (\$line => $pre, %opt);
1495            }            }
1496          }          }
1497          if (ref $pre) {          if (ref $pre) {
# Line 590  Function: Line 1503  Function:
1503                                               namespace_uri => $NS_XHTML1,                                               namespace_uri => $NS_XHTML1,
1504                                               local_name => 'pre');                                               local_name => 'pre');
1505          $pre->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI);          $pre->set_attribute (space => 'preserve', namespace_uri => NS_xml_URI);
1506          __FUNCPACK__->inline_text_to_xml (\$line => $pre);          __FUNCPACK__->inline_text_to_xml (\$line => $pre, %opt);
1507          while ($$source =~ /\G([^\x0A]*)\x0A/gc) {          while ($$source =~ /\G([^\x0A]*)\x0A/gc) {
1508            my $line = $1;            my $line = $1;
1509            if (length $line == 0) {            if (length $line == 0) {
1510              pos ($$source) -= 1;              pos ($$source) -= 1;
1511              last;              last;
1512              } elsif ($opt{return_by_INS} and $line =~ /^\]INS\]\s*$/) {
1513                return;
1514              } elsif ($opt{return_by_DEL} and $line =~ /^\]DEL\]\s*$/) {
1515                return;
1516            } else {            } else {
1517              $pre->append_text ("\x0A");              $pre->append_text ("\x0A");
1518              __FUNCPACK__->inline_text_to_xml (\$line => $pre);              __FUNCPACK__->inline_text_to_xml (\$line => $pre, %opt);
1519            }            }
1520          }          }
1521        } elsif ($line =~ /^,/) {        } elsif ($line =~ /^,/) {
# Line 609  Function: Line 1526  Function:
1526                              ->append_new_node (type => '#element',                              ->append_new_node (type => '#element',
1527                                                 namespace_uri => $NS_XHTML2,                                                 namespace_uri => $NS_XHTML2,
1528                                                 local_name => 'tbody');                                                 local_name => 'tbody');
1529          __FUNCPACK__->tablerow_text_to_xml (\$line => $tbody);          __FUNCPACK__->tablerow_text_to_xml (\$line => $tbody, %opt);
1530          while ($$source =~ /\G(,[^\x0A]*)\x0A/gc) {          while ($$source =~ /\G(,[^\x0A]*)\x0A/gc) {
1531            __FUNCPACK__->tablerow_text_to_xml (\"$1" => $tbody);            __FUNCPACK__->tablerow_text_to_xml (\"$1" => $tbody, %opt);
1532          }          }
1533        } else {        } else {
1534          my $current_type = $current->local_name;          my $current_type = $current->local_name;
1535          if ($current_type eq 'section'          if ($current_type eq 'section'
1536           or $current_type eq 'body'           or $current_type eq 'body'
1537           or $current_type eq 'bodytext'           or $current_type eq 'bodytext'
1538           or $current_type eq 'ins'           or $current_type eq 'insert'
1539           or $current_type eq 'del') {           or $current_type eq 'delete') {
1540            $current->append_text ("\x0A");            $current->append_text ("\x0A");
1541            if ($line =~ s/^__&&([^&]+)&&__//) {            if ($line =~ s/^__&&([^&]+)&&__//) {
1542              $current->append_new_node (type => '#element',              $current->append_new_node (type => '#element',
# Line 632  Function: Line 1549  Function:
1549                                              local_name => 'form')) {                                              local_name => 'form')) {
1550                $_->set_attribute (id => $1) if $1;                $_->set_attribute (id => $1) if $1;
1551                my ($i, $t, $o) = ($2, $3 || '', $4 || '');                my ($i, $t, $o) = ($2, $3 || '', $4 || '');
1552                s/\\(.)/$1/g for $i, $t, $o;                s/\\(.)/$1/g for ($i, $t, $o);
1553                $_->set_attribute (input => $i);                $_->set_attribute (input => $i);
1554                $_->set_attribute (template => $t);                $_->set_attribute (template => $t);
1555                $_->set_attribute (option => $o);                $_->set_attribute (option => $o);
# Line 646  Function: Line 1563  Function:
1563                $_->set_attribute (parameter => $3) if defined $3;                $_->set_attribute (parameter => $3) if defined $3;
1564              }              }
1565            }            }
1566            $current = $current->append_new_node            if (length $line) {
1567                                   (type => '#element',              $current = $current->append_new_node
1568                                    namespace_uri => $NS_XHTML2,                                     (type => '#element',
1569                                    local_name => 'p');                                      namespace_uri => $NS_XHTML2,
1570            __FUNCPACK__->inline_text_to_xml (\$line => $current);                                      local_name => 'p');
1571                __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1572              }        
1573          } else {          } else {
1574            $current->append_text (" "); # replacement of prev.line's \n            $current->append_text ("\x0A"); # replacement of prev.line's \n
1575            __FUNCPACK__->inline_text_to_xml (\$line => $current);            __FUNCPACK__->inline_text_to_xml (\$line => $current, %opt);
1576          }          }
1577        }        }
1578      }      }
# Line 676  Function: Line 1595  Function:
1595                                            local_name => 'tr');                                            local_name => 'tr');
1596      my $prev_cell;      my $prev_cell;
1597      while ($$source =~ /\G,\s*/gc) {      while ($$source =~ /\G,\s*/gc) {
1598        $$source =~ /\G([^,"]+|"(?>[^"\\]*)(?>(?>[^"\\]+|\\.)*)"\s*)/gc;        $$source =~ /\G([^,"][^,]*|"(?>[^"\\]*)(?>(?>[^"\\]+|\\.)*)"\s*)/gc;
1599        my $cell = $1;        my $cell = $1;
1600        if ($cell =~ s/^"//) {        if ($cell =~ s/^"//) {
1601          $cell =~ s/"\s*$//g;          $cell =~ s/"\s*$//g;
# Line 698  Function: Line 1617  Function:
1617                                 (type => '#element',                                 (type => '#element',
1618                                  namespace_uri => $NS_XHTML2,                                  namespace_uri => $NS_XHTML2,
1619                                  local_name => 'td');                                  local_name => 'td');
1620        __FUNCPACK__->inline_text_to_xml (\$cell => $prev_cell);        __FUNCPACK__->inline_text_to_xml (\$cell => $prev_cell, %opt);
1621      }      }
1622      # TODO: warn      # TODO: warn
1623    
# Line 709  Function: Line 1628  Function:
1628        SuikaWiki/0.9 text format to XML representation - inline level elements        SuikaWiki/0.9 text format to XML representation - inline level elements
1629      @@lang:en      @@lang:en
1630    @Main:    @Main:
1631        my (undef, $source => $current, %opt) = @_;
1632    
1633    my $ElementDef = {    my $ElementDef = {
1634      ABBR    => {ln => 'abbr', ns_uri => $NS_SW09},      ABBR    => {ln => 'abbr', ns_uri => $NS_XHTML2},
1635      CODE    => {ln => 'code', ns_uri => $NS_XHTML2},      CODE    => {ln => 'code', ns_uri => $NS_XHTML2},
1636      DEL     => {ln => 'del',  ns_uri => $NS_XHTML1},      DEL     => {ln => 'del',  ns_uri => $NS_XHTML1},
1637      DFN     => {ln => 'dfn',  ns_uri => $NS_XHTML2},      DFN     => {ln => 'dfn',  ns_uri => $NS_XHTML2},
# Line 732  Function: Line 1653  Function:
1653      rt      => {ln => 'rt',   ns_uri => $NS_XHTML2, is_nested => 1},      rt      => {ln => 'rt',   ns_uri => $NS_XHTML2, is_nested => 1},
1654    };    };
1655    
     my (undef, $source => $current, %opt) = @_;  
1656      if ($$source =~ /\G\[([0-9]+)\]/gc) {      if ($$source =~ /\G\[([0-9]+)\]/gc) {
1657        for ($current->append_new_node (type => '#element',        for ($current->append_new_node (type => '#element',
1658                                        namespace_uri => $NS_SW09,                                        namespace_uri => $NS_SW09,
1659                                        local_name => 'anchor-end')) {                                        local_name => 'anchor-end')) {
1660          $_->set_attribute (anchor => 0+$1);          $_->set_attribute (anchor => 0+$1,
1661                               namespace_uri => $NS_SW09);
1662          $_->append_text ('['.$1.']');          $_->append_text ('['.$1.']');
1663        }        }
1664      }      }
# Line 749  Function: Line 1670  Function:
1670                                                local_name => 'form');                                                local_name => 'form');
1671          if ($$source =~ /\G$Reg_Form_Content_M\]\]/ogc) {          if ($$source =~ /\G$Reg_Form_Content_M\]\]/ogc) {
1672            $form->set_attribute (id => $1) if $1;            $form->set_attribute (id => $1) if $1;
1673            $form->set_attribute (input => $2);            my ($i, $t, $o) = ($2, $3, $4);
1674            $form->set_attribute (template => $3);            s/\\(.)/$1/g for ($i, $t, $o);
1675            $form->set_attribute (option => $4);            $form->set_attribute (input => $i);
1676              $form->set_attribute (template => $t);
1677              $form->set_attribute (option => $o);
1678          } elsif ($$source =~ /\G$Reg_Embed_Content_M\]\]/ogc) {          } elsif ($$source =~ /\G$Reg_Embed_Content_M\]\]/ogc) {
1679            $form->set_attribute (ref => $1);            $form->set_attribute (ref => $1);
1680            $form->set_attribute (id => $2) if $2;            $form->set_attribute (id => $2) if $2;
1681            $form->set_attribute (parameter => $3) if defined $3;            $form->set_attribute (parameter => $3) if defined $3;
1682          } else {          } else {
1683            ## TODO: error            ## TODO: error
1684            CORE::die $$source;            SuikaWiki::Plugin->module_package('Error')->report_error_simple ($opt{opt}->{o}->{wiki}, InvalidForm => substr ($$source, pos ($$source)));
1685          }          }
1686        } elsif ($$source =~ /\G\[(?>([A-Z]+)(?>\(([^)]*)\))?)?\[/gc) {        } elsif ($$source =~ /\G\[(?>([A-Z]+)(?>\(((?>[^()\\]*)(?>(?>[^()\\]+|\\.)*))\))?)?\[/gc) {
1687          my $type = $1 || 'anchor';          my $type = $1 || 'anchor';
1688          my $param = $2;          my $param = $2;
1689          my $def = $ElementDef->{ $type };          my $def = $ElementDef->{ $type };
1690          unless ($def) {          unless ($def) {
1691            ## TODO: error            ## TODO: error
1692              $def = $ElementDef->{CODE};
1693          }          }
1694          $current = $current->append_new_node (type => '#element',          $current = $current->append_new_node (type => '#element',
1695                                                namespace_uri => $def->{ns_uri},                                                namespace_uri => $def->{ns_uri},
# Line 789  Function: Line 1713  Function:
1713          }          }
1714          my $def = $ElementDef->{$current->local_name} || {};          my $def = $ElementDef->{$current->local_name} || {};
1715          if (defined $anchor) {          if (defined $anchor) {
1716            if ($def->{has_fragment_no}) {            $current->set_attribute (anchor => $anchor + 0,
1717              $current->set_attribute (anchor => $anchor + 0);                                     namespace_uri => $NS_SW09);
           } else {  
             $current->set_attribute (anchor => $anchor + 0,  
                                      namespace_uri => $NS_SW09);  
           }  
1718          } elsif (defined $scheme) {          } elsif (defined $scheme) {
1719            if ($def->{has_cite}) {            if ($scheme =~ /[A-Z]/) {
1720              $current->set_attribute (cite => "$scheme:$opaque");              $current->set_attribute (resScheme => $scheme,
1721                                         namespace_uri => $NS_SW09);
1722                $current->set_attribute (resParameter => $opaque,
1723                                         namespace_uri => $NS_SW09);
1724            } else {            } else {
1725              $current->set_attribute (cite => "$scheme:$opaque",              $current->set_attribute (resScheme => 'URI',
1726                                         namespace_uri => $NS_SW09);
1727                $current->set_attribute (resParameter => "$scheme:$opaque",
1728                                       namespace_uri => $NS_SW09);                                       namespace_uri => $NS_SW09);
1729            }            }
1730          }          }
1731          $current = $current->parent_node;          $current = $current->parent_node;
1732          $current = $current->parent_node if $def->{is_nested};          $current = $current->parent_node if $def->{is_nested};
1733          $depth--;          $depth--;
1734        } elsif ($$source =~ /\G\]\s+\[/gc) {        } elsif ($$source =~ /\G\]\s*\[/gc) {
1735          if ($current->local_name eq 'rb' or $current->local_name eq 'rt') {          if ($current->local_name eq 'rb' or $current->local_name eq 'rt') {
1736            $current = $current->parent_node            $current = $current->parent_node
1737                               ->append_new_node                               ->append_new_node
# Line 814  Function: Line 1739  Function:
1739                                    namespace_uri => $ElementDef->{rt}->{ns_uri},                                    namespace_uri => $ElementDef->{rt}->{ns_uri},
1740                                    local_name => $ElementDef->{rt}->{ln});                                    local_name => $ElementDef->{rt}->{ln});
1741          } else {          } else {
1742            $current->append_text ($$source, $-[0], $+[0]-$-[0]);            $current->append_text (substr ($$source, $-[0], $+[0]-$-[0]-1));
1743              pos ($$source)--;
1744          }          }
1745        } elsif ($$source =~ /\G'''?/gc) {        } elsif ($$source =~ /\G'''?/gc) {
1746          my $type = $+[0] - $-[0] == 3 ? 'strong' : 'em';          my $type = $+[0] - $-[0] == 3 ? 'strong' : 'em';
# Line 826  Function: Line 1752  Function:
1752                                    namespace_uri => $NS_XHTML2,                                    namespace_uri => $NS_XHTML2,
1753                                    local_name => $type);                                    local_name => $type);
1754          }          }
1755        } elsif ($$source =~ /\G<([0-9A-Za-z_+.%-]+):($Reg_URI_Opaque)>/gc) {        } elsif ($$source =~ /\G<([0-9A-Za-z_+.%-]+):($Reg_URI_Opaque)>/gco) {
1756          my ($scheme, $data) = ($1, $2);          my ($scheme, $data) = ($1, $2);
1757          my $link = $current->append_new_node          my $link = $current->append_new_node
1758                                   (type => '#element',                                   (type => '#element',
1759                                    namespace_uri => $NS_SW09,                                    namespace_uri => $NS_SW09,
1760                                    local_name => 'anchor-external');                                    local_name => 'anchor-external');
1761          if (substr ($scheme, 0, 1) =~ /[A-Z]/) {          if (substr ($scheme, 0, 1) =~ /[A-Z]/) {
1762            $link->set_attribute (scheme => $scheme);            $link->set_attribute (resScheme => $scheme,
1763            $link->set_attribute (data => $data);                                  namespace_uri => $NS_SW09);
1764              $link->set_attribute (resParameter => $data,
1765                                    namespace_uri => $NS_SW09);
1766          } else { # URI Reference          } else { # URI Reference
1767            $link->set_attribute (href => $scheme.':'.$data);            $link->set_attribute (resScheme => 'URI',
1768                                    namespace_uri => $NS_SW09);
1769              $link->set_attribute (resParameter => $scheme.':'.$data,
1770                                    namespace_uri => $NS_SW09);
1771          }          }
1772            $link->append_text ($scheme.':'.$data);
1773        } elsif ($$source =~ /\G__&&/gc) {        } elsif ($$source =~ /\G__&&/gc) {
1774          if ($$source =~ /\G([^&]+)&&__/gc) {          if ($$source =~ /\G([^&]+)&&__/gc) {
1775            $current->append_new_node            $current->append_new_node
# Line 849  Function: Line 1781  Function:
1781            $current->append_text ('__&&');            $current->append_text ('__&&');
1782          }          }
1783        } elsif ($$source =~ /\G((?>        } elsif ($$source =~ /\G((?>
1784                                    [^'\[\]<>]+                                    [^'\[\]<>_]+
1785                                  | '   (?!')                                  | '   (?!')
1786                                  | \[  (?![A-Z\[])                                  | \[  (?!\[|[A-Z]+(?>\([^()\\]*
1787                                                           (?>[^()\\]+|\\.)*\))?\[)
1788                                  | \]  (?! \]                                  | \]  (?! \]
1789                                          | >>[0-9]+\]                                          | >>[0-9]+\]
1790                                          | <[0-9A-Za-z_+.%-]+:$Reg_URI_Opaque>\]                                          | <[0-9A-Za-z_+.%-]+:$Reg_URI_Opaque>\]
# Line 865  Function: Line 1798  Function:
1798          for ($current->append_new_node (type => '#element',          for ($current->append_new_node (type => '#element',
1799                                          namespace_uri => $NS_SW09,                                          namespace_uri => $NS_SW09,
1800                                          local_name => 'anchor-internal')) {                                          local_name => 'anchor-internal')) {
1801            $_->set_attribute (anchor => 0+$1);            $_->set_attribute (anchor => 0+$1,
1802                                 namespace_uri => $NS_SW09);
1803            $_->append_text ('>>'.$1);            $_->append_text ('>>'.$1);
1804          }          }
1805        } else {        } else {
1806          die "Implementation buggy: ", substr ($$source, pos $$source);          CORE::die "Implementation buggy: ", substr ($$source, pos $$source);
1807        }        }
1808      }      }
1809    
 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;  
           }  
   
1810  FormattingRule:  FormattingRule:
1811    @Category[list]: page-link    @Category[list]:
1812        page-link
1813        link-to-resource
1814    @Name: sw09--link-anchor-content    @Name: sw09--link-anchor-content
1815    @Description:    @Description:
1816      @@@:      @@@:
# Line 1292  FormattingRule: Line 1820  FormattingRule:
1820      if ($o->{var}->{sw09__anchor_content}) {      if ($o->{var}->{sw09__anchor_content}) {
1821        $o->{var}->{sw09__anchor_content}->($p->{-parent});        $o->{var}->{sw09__anchor_content}->($p->{-parent});
1822      } else {      } else {
1823        $p->{-parent}->append_node (SuikaWiki::Plugin->resource        $WIKIRESOURCE->append_tree
1824                        ('Link:SuikaWiki/0.9:link-anchor-content:InvalidContext'),              (name => 'Link:SuikaWiki/0.9:link-anchor-content:InvalidContext',
1825                                    node_or_text => 1);               param => $o,
1826                 -parent => $p->{-parent},
1827                 wiki => $o->{wiki});
1828      }      }
1829    
1830  Resource:  Resource:
1831    @Link:SuikaWiki/0.9:link-anchor-content:InvalidContext:    @Link:SuikaWiki/0.9:link-anchor-content:InvalidContext:
1832      @@@: %sw09--link-anchor-content; cannot be used in this context.      @@@: %percent;sw09--link-anchor-content; cannot be used in this context.
1833        @@lang:en
1834      @Link:SuikaWiki/0.9:toResource:SourceLabel:
1835        @@@:
1836          %select_link_resource_scheme (
1837            URI => {<%link-to-it(
1838              label=>{%link-resource-parameters;}p,
1839            );>},
1840            MAIL => {<%link-to-it(
1841              label => {%link-resource-parameters;}p,
1842              description
1843                => {%res (name=>{Link:MailAddress=});<%link-resource-parameters;>}p,
1844            );>},
1845            otherwise => {<%link-to-it(
1846              label => {%sw09--link-anchor-content;}p,
1847              description => {%res (name=>{Link:URIReference=});<%uri-reference;>}p,
1848            );>},
1849          );
1850      @@lang:en      @@lang:en
1851    @Link:SuikaWiki/0.9:toWikiPage:SourceLabel:    @Link:SuikaWiki/0.9:toWikiPage:SourceLabel:
1852      @@@:      @@@:
# Line 1314  Resource: Line 1861  Resource:
1861          );}p,          );}p,
1862          class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,          class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,
1863        );        );
1864      @SuikaWiki/0.9:form:comment:input:
1865          %line (content => {%textarea (id=>msg,size=>20,lines=>3);}p);
1866          %line (content => {
1867            (%text (description => {%res (name => {Form:Description:HumanName});}p,
1868                    id => name, size => 6);
1869             [%text (description =>
1870                       {%res (name => {Form:Description:MailAddress});}p,
1871                     id => mail, size => 5);]
1872             %check (default, id => record-date,
1873                     label => {%res (name => {Form:Label:LogDate});}p,
1874                     description => {%res (name => {Form:Description:LogDate});}p);)
1875             %submit (label => {%res (name => {Form:Label:Add});}p,
1876                      description => {%res (name => {Form:Description:Add});}p);
1877             %we--update-lastmodified-datetime;
1878          }p);
1879      @SuikaWiki/0.9:form:comment:template:
1880        %n
1881       ;[%index;]%n
1882       ;%text(source=>msg);%n;(%name;%text(source=>mail,prefix=>" [",suffix=>"]");%iif(source=>record-date,true=>" [WEAK[%date;]]");)%n;
1883      @SuikaWiki/0.9:form:comment:option:
1884        %require (msg);
1885      @SuikaWiki/0.9:form:footannotate:input:
1886          %line (content => {%textarea (id=>msg,size=>20,lines=>3);}p);
1887          %line (content => {
1888            (%text (description => {%res (name => {Form:Description:HumanName});}p,
1889                    id => name, size => 6);
1890             [%text (description =>
1891                       {%res (name => {Form:Description:MailAddress});}p,
1892                     id => mail, size => 5);]
1893             %check (default, id => record-date,
1894                     label => {%res (name => {Form:Label:LogDate});}p,
1895                     description => {%res (name => {Form:Description:LogDate});}p);)
1896             %submit (label => {%res (name => {Form:Label:Add});}p,
1897                      description => {%res (name => {Form:Description:Add});}p);
1898             %we--update-lastmodified-datetime;
1899          }p);
1900      @SuikaWiki/0.9:form:footannotate:template:
1901         %n
1902        ;[%index;]%n
1903        ;%text(source=>msg);%n
1904        ;(%name;%text(source=>mail,prefix=>" [",suffix=>"]");%iif(source=>record-date,true=>" [WEAK[%date;]]");)%n;
1905      @SuikaWiki/0.9:form:footannotate:option:
1906        %require (msg);
1907    
1908    Error:
1909      @Name: text_parse
1910      @Definition:
1911        @@INLINE_NO_CLOSE_TAG:
1912          @@@description:
1913            Close tag of element "%t (name => element_type);" not found.
1914          @@@level: non-fatal
1915        @@BLOCK_NO_CLOSE_TAG:
1916          @@@description:
1917            Close tag of element "%t (name => element_type);" not found.
1918          @@@level: non-fatal
1919        @@INVALID_FORM:
1920          @@@description:
1921            Invalid syntax of WikiForm
1922          @@@level: non-fatal
1923        
1924    Error:
1925      @Name: xml_to_text
1926      @IsA[list]:
1927        ::SuikaWiki::Format::
1928      @Definition:
1929        @@

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24