forked from ingydotnet/wikitext-pm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.kwiki.org/kwiki/trunk/src/ingy/WikiText@282 4b3b33bc-d223-0410-9309-b363ae52eedd
- Loading branch information
ingy
committed
Feb 12, 2008
0 parents
commit ff4a6f7
Showing
33 changed files
with
1,419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
version: 0.10 | ||
date: Mon Feb 11 23:44:02 PST 2008 | ||
changes: Maiden voyage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Changes | ||
inc/Module/Install.pm | ||
inc/Module/Install/Base.pm | ||
inc/Module/Install/Can.pm | ||
inc/Module/Install/Fetch.pm | ||
inc/Module/Install/Include.pm | ||
inc/Module/Install/Makefile.pm | ||
inc/Module/Install/Metadata.pm | ||
inc/Module/Install/TestBase.pm | ||
inc/Module/Install/Win32.pm | ||
inc/Module/Install/WriteAll.pm | ||
inc/Spiffy.pm | ||
inc/Test/Base.pm | ||
inc/Test/Base/Filter.pm | ||
inc/Test/Builder.pm | ||
inc/Test/Builder/Module.pm | ||
inc/Test/More.pm | ||
lib/WikiText.pm | ||
lib/WikiText/Creole.pm | ||
lib/WikiText/DokuWiki.pm | ||
lib/WikiText/HTML.pm | ||
lib/WikiText/HTML/Emitter.pm | ||
lib/WikiText/Kwiki.pm | ||
lib/WikiText/MediaWiki.pm | ||
lib/WikiText/MoinMoin.pm | ||
lib/WikiText/OddMuse.pm | ||
lib/WikiText/Parser.pm | ||
lib/WikiText/PBWiki.pm | ||
lib/WikiText/Pod.pm | ||
lib/WikiText/PurpleWiki.pm | ||
lib/WikiText/Receiver.pm | ||
lib/WikiText/Sample.pm | ||
lib/WikiText/Sample/Parser.pm | ||
lib/WikiText/Socialtext.pm | ||
lib/WikiText/TiddlyWiki.pm | ||
lib/WikiText/Trac.pm | ||
lib/WikiText/TWiki.pm | ||
lib/WikiText/UseMod.pm | ||
lib/WikiText/Wifty.pm | ||
lib/WikiText/WikiByte.pm | ||
lib/WikiText/WikiByte/Emitter.pm | ||
lib/WikiText/Wikiwyg.pm | ||
Makefile.PL | ||
MANIFEST This list of files | ||
META.yml | ||
README | ||
t/data/sample | ||
t/sample_to_html.t | ||
t/sample_to_wikibyte.t | ||
t/TestWikiText.pm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use inc::Module::Install; | ||
|
||
name 'WikiText'; | ||
all_from 'lib/WikiText.pm'; | ||
|
||
requires perl => '5.6.1'; | ||
|
||
use_test_base; | ||
|
||
WriteAll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
NAME | ||
WikiText - Wiki Text Conversion Tools | ||
|
||
SYNOPSIS | ||
my $parser = WikiText::Sample::Parser->new( | ||
receiver => WikiText::HTML::Emitter->new, | ||
); | ||
|
||
my $wikitext = " | ||
== A Title | ||
|
||
This is some text that contains a '''bold phrase''' in it. | ||
"; | ||
|
||
my $html = $parser->parse(shift); | ||
|
||
DESCRIPTION | ||
The WikiText modules parse documents in various formats. A parse has a | ||
receiver. The receiver takes the parse events and creates a new form. | ||
The new form can be HTML, an AST or another wiki markup. | ||
|
||
Some formats are richer than others. The module WikiText::WikiByte | ||
defines a bytecode format. The bytecode format is rich enough to be a | ||
receiver for any parse, therefore it makes an ideal intermediate format. | ||
|
||
AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
|
||
COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
|
||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
|
||
See http://www.perl.com/perl/misc/Artistic.html | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package WikiText; | ||
use strict; | ||
use warnings; | ||
|
||
use 5.006.001; | ||
our $VERSION = '0.05'; | ||
|
||
1; | ||
|
||
=head1 NAME | ||
WikiText - Wiki Text Conversion Tools | ||
=head1 SYNOPSIS | ||
use WikiText::Sample::Parser; | ||
use WikiText::HTML::Emitter; | ||
my $parser = WikiText::Sample::Parser->new( | ||
receiver => WikiText::HTML::Emitter->new, | ||
); | ||
my $wikitext = "== A Title | ||
This is some text that contains a '''bold phrase''' in it. | ||
"; | ||
my $html = $parser->parse($wikitext); | ||
=head1 DESCRIPTION | ||
The WikiText modules parse documents in various formats. A parse has a | ||
receiver. The receiver takes the parse events and creates a new form. The new | ||
form can be HTML, an AST or another wiki markup. | ||
Some formats are richer than others. The module WikiText::WikiByte defines a | ||
bytecode format. The bytecode format is rich enough to be a receiver for any | ||
parse, therefore it makes an ideal intermediate format. | ||
=head1 AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
=head1 COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
See http://www.perl.com/perl/misc/Artistic.html | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package WikiText::Creole; | ||
|
||
1; | ||
|
||
=head1 NAME | ||
WikiText::Creole - Creole WikiText Module | ||
=head1 SYNOPSIS | ||
use WikiText::Creole; | ||
=head1 DESCRIPTION | ||
Placeholder module for Creole. Coming soon. | ||
=head1 AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
=head1 COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
See http://www.perl.com/perl/misc/Artistic.html | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package WikiText::DokuWiki; | ||
|
||
1; | ||
|
||
=head1 NAME | ||
WikiText::DokuWiki - DokuWiki WikiText Module | ||
=head1 SYNOPSIS | ||
use WikiText::DokuWiki; | ||
=head1 DESCRIPTION | ||
Placeholder module for DokuWiki. Coming soon. | ||
=head1 AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
=head1 COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
See http://www.perl.com/perl/misc/Artistic.html | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package WikiText::HTML; | ||
|
||
1; | ||
|
||
=head1 NAME | ||
WikiText::HTML - HTML WikiText Module | ||
=head1 SYNOPSIS | ||
use WikiText::HTML; | ||
=head1 DESCRIPTION | ||
Placeholder module for HTML. Coming soon. | ||
=head1 AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
=head1 COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
See http://www.perl.com/perl/misc/Artistic.html | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package WikiText::HTML::Emitter; | ||
use strict; | ||
use warnings; | ||
|
||
use base 'WikiText::Receiver'; | ||
use CGI::Util; | ||
|
||
my $type_tags = { | ||
b => 'strong', | ||
i => 'em', | ||
wikilink => 'a', | ||
}; | ||
|
||
sub init { | ||
my $self = shift; | ||
$self->{output} = ''; | ||
} | ||
|
||
sub content { | ||
my $self = shift; | ||
return $self->{output}; | ||
} | ||
|
||
sub insert { | ||
my $self = shift; | ||
my $ast = shift; | ||
$self->{output} .= $ast->{output} || ''; | ||
} | ||
|
||
sub uri_escape { | ||
$_ = shift; | ||
s/ /\%20/g; | ||
return $_; | ||
} | ||
|
||
sub begin_node { | ||
my $self = shift; | ||
my $node = shift; | ||
my $type = $node->{type}; | ||
my $tag = $type_tags->{$type} || $type; | ||
# XXX For tables maybe... | ||
# $tag =~ s/-.*//; | ||
$self->{output} .= | ||
($tag =~ /^(br|hr)$/) | ||
? "<$tag />\n" | ||
: ($type eq "wikilink") | ||
? $self->begin_wikilink($node) | ||
: "<$tag>" . | ||
($tag =~ /^(ul|ol|table|tr)$/ ? "\n" : ""); | ||
} | ||
|
||
sub begin_wikilink { | ||
my $self = shift; | ||
my $node = shift; | ||
my $tag = $node->{type}; | ||
|
||
my $link = $self->{callbacks}{wikilink} | ||
? $self->{callbacks}{wikilink}->($node) | ||
: CGI::Util::escape($node->{attributes}{target}); | ||
return qq{<a href="$link">}; | ||
} | ||
|
||
sub end_node { | ||
my $self = shift; | ||
my $node = shift; | ||
my $type = $node->{type}; | ||
my $tag = $type_tags->{$type} || $type; | ||
$tag =~ s/-.*//; | ||
return if ($tag =~ /^(br|hr)$/); | ||
if ($tag eq "wikilink") { | ||
$self->{output} .= '</a>'; | ||
return; | ||
} | ||
$self->{output} .= "</$tag>" . | ||
($tag =~ /^(p|hr|ul|ol|li|h\d|table|tr|td)$/ ? "\n" : ""); | ||
} | ||
|
||
sub text_node { | ||
my $self = shift; | ||
my $text = shift; | ||
$self->{output} .= "$text"; | ||
} | ||
|
||
1; | ||
|
||
=head1 NAME | ||
WikiText::HTML::Emitter - A WikiText Receiver That Generates HTML | ||
=head1 SYNOPSIS | ||
use WikiText::HTML::Emitter; | ||
=head1 DESCRIPTION | ||
This receiver module, when hooked up to a parser, produces HTML. | ||
=head1 AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
=head1 COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
See http://www.perl.com/perl/misc/Artistic.html | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package WikiText::Kwiki; | ||
|
||
1; | ||
|
||
=head1 NAME | ||
WikiText::Kwiki - Kwiki WikiText Module | ||
=head1 SYNOPSIS | ||
use WikiText::Kwiki; | ||
=head1 DESCRIPTION | ||
Placeholder module for Kwiki. Coming soon. | ||
=head1 AUTHOR | ||
Ingy döt Net <ingy@cpan.org> | ||
=head1 COPYRIGHT | ||
Copyright (c) 2008. Ingy döt Net. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the same terms as Perl itself. | ||
See http://www.perl.com/perl/misc/Artistic.html | ||
=cut |
Oops, something went wrong.