| 1 | package Pod::Simple::Wiki::Wikka; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 4 | ▶ | use Pod::Simple::Wiki; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | 4 | ▶ | use vars qw(@ISA $VERSION); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 4 | @ISA = qw(Pod::Simple::Wiki); | |||||||||||||||||
| 9 | 4 | $VERSION = '0.09'; | |||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | ############################################################################### | ||||||||||||||||||
| 12 | # | ||||||||||||||||||
| 13 | # The tag to wiki mappings. | ||||||||||||||||||
| 14 | # | ||||||||||||||||||
| 15 | 4 | my $tags = { | |||||||||||||||||
| 16 | '<b>' => '**', | ||||||||||||||||||
| 17 | '</b>' => '**', | ||||||||||||||||||
| 18 | '<i>' => '//', | ||||||||||||||||||
| 19 | '</i>' => '//', | ||||||||||||||||||
| 20 | '<tt>' => '##', | ||||||||||||||||||
| 21 | '</tt>' => '##', | ||||||||||||||||||
| 22 | '<pre>' => '', | ||||||||||||||||||
| 23 | '</pre>' => "\n\n", | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | '<h1>' => "\n====== ", | ||||||||||||||||||
| 26 | '</h1>' => " ======\n\n", | ||||||||||||||||||
| 27 | '<h2>' => "\n===== ", | ||||||||||||||||||
| 28 | '</h2>' => " =====\n\n", | ||||||||||||||||||
| 29 | '<h3>' => "\n==== ", | ||||||||||||||||||
| 30 | '</h3>' => " ====\n\n", | ||||||||||||||||||
| 31 | '<h4>' => "\n=== ", | ||||||||||||||||||
| 32 | '</h4>' => " ===\n\n", | ||||||||||||||||||
| 33 | }; | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | ############################################################################### | ||||||||||||||||||
| 36 | # | ||||||||||||||||||
| 37 | # new() | ||||||||||||||||||
| 38 | # | ||||||||||||||||||
| 39 | # Simple constructor inheriting from Pod::Simple::Wiki. | ||||||||||||||||||
| 40 | # | ||||||||||||||||||
| 41 | 23 | ▶ | sub new { | ||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | 23 | my $class = shift; | |||||||||||||||||
| 44 | 23 | my $self = Pod::Simple::Wiki->new('wiki', @_); | |||||||||||||||||
| 45 | 23 | $self->{_tags} = $tags; | |||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | 23 | bless $self, $class; | |||||||||||||||||
| 48 | 23 | return $self; | |||||||||||||||||
| 49 | } | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | ############################################################################### | ||||||||||||||||||
| 52 | # | ||||||||||||||||||
| 53 | # _indent_item() | ||||||||||||||||||
| 54 | # | ||||||||||||||||||
| 55 | # Indents an "over-item" to the correct level. | ||||||||||||||||||
| 56 | # | ||||||||||||||||||
| 57 | 37 | ▶ | sub _indent_item { | ||||||||||||||||
|
Subroutine
_indent_item: called CC=4 SCAR=13.9
| |||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | 37 | my $self = shift; | |||||||||||||||||
| 60 | 37 | my $item_type = $_[0]; | |||||||||||||||||
| 61 | 37 | my $item_param = $_[1]; | |||||||||||||||||
| 62 | 37 | my $indent_level = $self->{_item_indent}; | |||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | 37 | ▶ | if ($item_type eq 'bullet') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 65 | 12 | $self->_append('~' x $indent_level . '- '); | |||||||||||||||||
| 66 | } | ||||||||||||||||||
| 67 | elsif ($item_type eq 'number') { | ||||||||||||||||||
| 68 | 12 | $self->_append('~' x $indent_level . '1) '); | |||||||||||||||||
| 69 | } | ||||||||||||||||||
| 70 | elsif ($item_type eq 'text') { | ||||||||||||||||||
| 71 | 13 | $self->_append('~' x $indent_level . ''); | |||||||||||||||||
| 72 | } | ||||||||||||||||||
| 73 | } | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | ############################################################################### | ||||||||||||||||||
| 76 | # | ||||||||||||||||||
| 77 | # _handle_text() | ||||||||||||||||||
| 78 | # | ||||||||||||||||||
| 79 | # Perform any necessary transforms on the text. This is mainly used to escape | ||||||||||||||||||
| 80 | # inadvertent CamelCase words. | ||||||||||||||||||
| 81 | # | ||||||||||||||||||
| 82 | 60 | ▶ | sub _handle_text { | ||||||||||||||||
|
Subroutine
_handle_text: called CC=2 SCAR=6.9
| |||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | 60 | my $self = shift; | |||||||||||||||||
| 85 | 60 | my $text = $_[0]; | |||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | # Only escape words in paragraphs | ||||||||||||||||||
| 88 | 60 | ▶ | if (not $self->{_in_Para}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 89 | 41 | $self->{_wiki_text} .= $text; | |||||||||||||||||
| 90 | 41 | return; | |||||||||||||||||
| 91 | } | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | # Split the text into tokens but maintain the whitespace | ||||||||||||||||||
| 94 | 19 | my @tokens = split /(\s+)/, $text; | |||||||||||||||||
| 95 | |||||||||||||||||||
| 96 | # Portme: | ||||||||||||||||||
| 97 | # Escape any tokens here, if necessary. | ||||||||||||||||||
| 98 | |||||||||||||||||||
| 99 | # Rejoin the tokens and whitespace. | ||||||||||||||||||
| 100 | 19 | $self->{_wiki_text} .= join '', @tokens; | |||||||||||||||||
| 101 | } | ||||||||||||||||||
| 102 | |||||||||||||||||||
| 103 | |||||||||||||||||||
| 104 | ############################################################################### | ||||||||||||||||||
| 105 | # | ||||||||||||||||||
| 106 | # Functions to deal with =over ... =back regions for | ||||||||||||||||||
| 107 | # | ||||||||||||||||||
| 108 | # Bulleted lists | ||||||||||||||||||
| 109 | # Numbered lists | ||||||||||||||||||
| 110 | # Text lists | ||||||||||||||||||
| 111 | # Block lists | ||||||||||||||||||
| 112 | # | ||||||||||||||||||
| 113 | 13 | ▶ | sub _end_item_text {$_[0]->_output("\n")} | ||||||||||||||||
|
Subroutine
_end_item_text: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 114 | |||||||||||||||||||
| 115 | |||||||||||||||||||
| 116 | ############################################################################### | ||||||||||||||||||
| 117 | # | ||||||||||||||||||
| 118 | # _start_Para() | ||||||||||||||||||
| 119 | # | ||||||||||||||||||
| 120 | # Special handling for paragraphs that are part of an "over" block. | ||||||||||||||||||
| 121 | # | ||||||||||||||||||
| 122 | 19 | ▶ | sub _start_Para { | ||||||||||||||||
|
Subroutine
_start_Para: called CC=2 SCAR=6.9
| |||||||||||||||||||
| 123 | |||||||||||||||||||
| 124 | 19 | my $self = shift; | |||||||||||||||||
| 125 | 19 | my $indent_level = $self->{_item_indent}; | |||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | 19 | ▶ | if ($self->{_in_over_block}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 128 | # Do something here is necessary | ||||||||||||||||||
| 129 | } | ||||||||||||||||||
| 130 | } | ||||||||||||||||||
| 131 | |||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | 4 | 1; | |||||||||||||||||
| 134 | |||||||||||||||||||
| 135 | |||||||||||||||||||
| 136 | __END__ | ||||||||||||||||||