~ubuntu-branches/ubuntu/oneiric/libhtml-wikiconverter-perl/oneiric

« back to all changes in this revision

Viewing changes to WikiConverter/PmWiki.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Genannt
  • Date: 2006-01-09 20:19:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060109201912-306xp7tjdjcwejlu
Tags: 0.40-1
New Upstream Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    tt     => { start => '@@', end => '@@', trim => 'both', line_format => 'single' },
27
27
    code   => { alias => 'tt' },
28
28
 
29
 
    big   => { start => '+',  end => '+',  line_format => 'single' },
30
 
    small => { start => '-',  end => '-',  line_format => 'single' },
31
 
    sup   => { start => '^',  end => '^',  line_format => 'single' },
32
 
    sub   => { start => '_',  end => '_',  line_format => 'single' },
 
29
    big   => { start => "'+", end => "+'", line_format => 'single' },
 
30
    small => { start => "'-", end => "-'", line_format => 'single' },
 
31
    sup   => { start => "'^", end => "^'", line_format => 'single' },
 
32
    sub   => { start => "'_", end => "_'", line_format => 'single' },
33
33
    ins   => { start => '{+', end => '+}', line_format => 'single' },
34
34
    del   => { start => '{-', end => '-}', line_format => 'single' },
35
35
 
105
105
 
106
106
sub _link {
107
107
  my( $self, $node, $rules ) = @_;
 
108
  return $self->_anchor($node, $rules) if $node->attr('name');
 
109
 
108
110
  my $url = $node->attr('href') || '';
109
111
  my $text = $self->get_elem_contents($node) || '';
 
112
 
 
113
  return $url if $text eq $url;
110
114
  return "[[$url | $text]]";
111
115
}
112
116
 
 
117
sub _anchor {
 
118
  my( $self, $node, $rules ) = @_;
 
119
  my $name = $node->attr('name') || '';
 
120
  return "[[#$name]]";
 
121
}
 
122
 
113
123
sub _image {
114
124
  my( $self, $node, $rules ) = @_;
115
125
  return $node->attr('src') || '';
117
127
 
118
128
sub preprocess_node {
119
129
  my( $self, $node ) = @_;
120
 
  $self->strip_aname($node) if $node->tag eq 'a';
121
 
  $self->caption2para($node) if $node->tag eq 'caption';
 
130
  my $tag = $node->tag || '';
 
131
  $self->_move_aname($node) if $tag eq 'a' and $node->attr('name');
 
132
  $self->caption2para($node) if $tag eq 'caption';
 
133
}
 
134
 
 
135
sub _move_aname {
 
136
  my( $self, $node ) = @_;
 
137
 
 
138
  my $name = $node->attr('name') || '';
 
139
  $node->attr( name => undef );
 
140
 
 
141
  my $aname = new HTML::Element( 'a', name => $name );
 
142
  $node->preinsert($aname);
 
143
 
 
144
  # Keep 'a href's around
 
145
  $node->replace_with_content->delete unless $node->attr('href');
122
146
}
123
147
 
124
148
1;
142
166
 
143
167
=head1 AUTHOR
144
168
 
145
 
David J. Iberri <diberri@yahoo.com>
 
169
David J. Iberri <diberri@cpan.org>
146
170
 
147
171
=head1 COPYRIGHT
148
172