Last active
August 29, 2015 14:00
-
-
Save alicraigmile/11304557 to your computer and use it in GitHub Desktop.
Prototype wiki markup converter - given trac format wiki code on STDIN, convert it to confluence format
This file contains hidden or 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
| #!/usr/bin/env perl | |
| # Prototype wiki markup converter - given trac format wiki code on STDIN, | |
| # convert it to confluence format. | |
| # | |
| # Last updated: 12/Jun/2008 | |
| # (c) 2008 Ali Craigmile | |
| # | |
| # Usage: | |
| # cat trac-wiki-code.txt | ./trac2confluence.pl | |
| # | |
| use strict; | |
| use warnings; | |
| my @data = <STDIN>; | |
| print trac2confluence (@data); | |
| sub trac2confluence | |
| { | |
| my @out = (); | |
| for (@_) { | |
| if ( /³3text³3/ ) { | |
| my @parts = split(/³3text³3/, $_, 2); | |
| $_ = "(" . ord($parts[$#parts]) . ") " . $parts[$#parts]; | |
| $_ = $parts[$#parts]; | |
| } elsif ( /³3/ ) { | |
| next; | |
| } | |
| $_ =~ s/^= /h1. /g; | |
| $_ =~ s/^== /h1. /g; | |
| $_ =~ s/^=== /h2. /g; | |
| $_ =~ s/ ===//g; | |
| $_ =~ s/ ==//g; | |
| $_ =~ s/ =//g; | |
| $_ =~ s/\*/\\*/g; | |
| $_ =~ s/-/\\-/g; | |
| $_ =~ s/<\/?b>/*/g; #bold | |
| $_ =~ s/¬/-/g; #strike | |
| $_ =~ s/<\/?em>/_/g; #italic | |
| $_ =~ s/\[\[/\[/g; | |
| $_ =~ s/\]\]/\]/g; | |
| $_ =~ s/\|\|/\|/g; # tables | |
| $_ =~ s/\|\'\'\'/||/g; # tables | |
| $_ =~ s/\'\'\'//g; # tables | |
| $_ =~ s/^(\\\*){3}/*/g; #fix fuckups | |
| $_ =~ s/^(\\\*){2}/*/g; #fix fuckups | |
| $_ =~ s/^(\\\*){1}/*/g; #fix fuckups | |
| $_ =~ s/(\\-){4}/----/g; #fix fuckups | |
| $_ =~ s/PC\\-/PC-/g; #fix fuckups | |
| push @out, $_; | |
| } | |
| return @out; | |
| } | |
| __DATA__ | |
| Put your suggestions and ideas about our websites in here. Please leave your name too. | |
| * [[Promonster]] - Link Submissions with Promos so that they can be copied and parsed properly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment