This file is indexed.

/usr/share/perl5/HTML/WikiConverter/Oddmuse.pm is in libhtml-wikiconverter-oddmuse-perl 0.52-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package HTML::WikiConverter::Oddmuse;

use warnings;
use strict;

use base 'HTML::WikiConverter';

our $VERSION = '0.52';

use Params::Validate ':types';

=head1 NAME

HTML::WikiConverter::Oddmuse - Convert HTML to Oddmuse markup

=head1 SYNOPSIS

  use HTML::WikiConverter;
  my $wc = new HTML::WikiConverter( dialect => 'Oddmuse' );
  print $wc->html2wiki( $html );

=head1 DESCRIPTION

This module contains rules for converting HTML into Oddmuse
markup. This dialect module supports most of Oddmuse's text formatting
rules described at [1], notably:

  * bold, strong, italic, emphasized, and underlined text
  * paragraph blocks
  * external images
  * internal and external links
  * unordered and ordered lists
  * tables [2]

 [1] http://www.oddmuse.org/cgi-bin/wiki/Text_Formatting_Rules
 [2] http://www.oddmuse.org/cgi-bin/wiki/Table_Markup_Extension

See L<HTML::WikiConverter> for usage details.

=head1 ATTRIBUTES

In addition to the regular set of attributes recognized by the
L<HTML::WikiConverter> constructor, this dialect also accepts the
following attributes:

=head2 camel_case

Boolean indicating whether CamelCase links are enabled in the target
Oddmuse installation. This corresponds to Oddmuse's C<$WikiLinks>
configuration parameter. Enabling CamelCase links will turn HTML like
this:

  <p><a href="/wiki/CamelCase">CamelCase</a> links are fun.</p>

into this Oddmuse markup:

  CamelCase links are fun.

Disabling CamelCase links (the default) would convert that HTML into

  [[CamelCase]] links are fun.

=cut

sub attributes { {
  camel_case => { default => 0, type => BOOLEAN }
} }

sub rules {
  my %rules = (
    b => { start => '*', end => '*' },
    strong => { alias => 'b' },
    i => { start => '/', end => '/' },
    em => { start => '~', end => '~' },
    u => { start => '_', end => '_' },
    
    p => { block => 1, trim => 'both', line_format => 'multi' },
    img => { replace => \&_image },
    a => { replace => \&_link },

    ul => { line_format => 'multi', block => 1 },
    ol => { alias => 'ul' },
    li => { start => \&_li_start, trim => 'leading' },

    # http://www.oddmuse.org/cgi-bin/wiki/Table_Markup_Extension
    table => { block => 1, line_format => 'multi' },
    tr => { line_format => 'single', end => "||\n" },
    td => { start => \&_td_start, end => \&_td_end, trim => 'both' },
    th => { alias => 'td' },

    h1 => { start => '=', end => '=', block => 1, line_format => 'single' },
    h2 => { start => '==', end => '==', block => 1, line_format => 'single' },
    h3 => { start => '===', end => '===', block => 1, line_format => 'single' },
    h4 => { start => '====', end => '====', block => 1, line_format => 'single' },
    h5 => { start => '=====', end => '=====', block => 1, line_format => 'single' },
    h6 => { start => '======', end => '======', block => 1, line_format => 'single' },
  );

  return \%rules;
}

sub _td_start {
  my( $self, $node, $rules ) = @_;
  my $align = $node->attr('align') || 'left';
  my $colspan = $node->attr('colspan') || 1;

  my $prefix = ( '||' ) x $colspan;
  my $pad_for_align = $align eq 'left' ? '' : ' ';
  return $prefix.$pad_for_align;
}

sub _td_end {
  my( $self, $node, $rules ) = @_;
  my $align = $node->attr('align') || 'left';
  return $align eq 'right' ? '' : ' ';
}

sub _link {
  my( $self, $node, $rules ) = @_;
  my $url = $node->attr('href') || '';
  my $text = $self->get_elem_contents($node) || '';
  
  if( my $title = $self->get_wiki_page($url) ) {
    $title =~ s/_/ /g;
    return $text if $self->camel_case and lc $title eq lc $text and $self->is_camel_case($text);
    return "[[$text]]" if lc $text eq lc $title;
    return "[[$title|$text]]";
  } else {
    return $url if $url eq $text;
    return "[$url $text]";
  }
}

sub _image {
  my( $self, $node, $rules ) = @_;
  my $src = $node->attr('src') || '';
  return '' unless $src;

  # Could do something with an 'image_uri' option to handle local images
  return $src;
}

sub _li_start {
  my( $self, $node, $rules ) = @_;
  my @parent_lists = $node->look_up( _tag => qr/ul|ol/ );
  my $prefix = ('*') x @parent_lists;
  return "\n$prefix ";
}

=head1 AUTHOR

David J. Iberri, C<< <diberri at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-html-wikiconverter-oddmuse at rt.cpan.org>, or through the web
interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-WikiConverter-Oddmuse>.
I will be notified, and then you'll automatically be notified of
progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc HTML::WikiConverter::Oddmuse

You can also look for information at:

=over 4

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/HTML-WikiConverter-Oddmuse>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/HTML-WikiConverter-Oddmuse>

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-WikiConverter-Oddmuse>

=item * Search CPAN

L<http://search.cpan.org/dist/HTML-WikiConverter-Oddmuse>

=back

=head1 COPYRIGHT & LICENSE

Copyright 2006 David J. Iberri, all rights reserved.

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;