About this wiki

Using “flat files” insteed of “database” make this wiki realy simple to backup and convert your documentation based on text file simpler.
I have wrotten a small perl script to the job, you just have to respect rules on your text file.

#!/usr/bin/perl
# A very simple script to creat basic wiki page
#
# If the line start by TT,*,CC then this script will process it:
#   TT = title 
#   * = section (add two space behind + bold + underline)
#   CC code CC = text bettwen CC will be code
#
# Also add \\ a the end of each line who is not starting by *,=,blanc 
# or ending by \\ and remove space after the last char.
#
# by Arnaud Marchal <rno@big-up.org>
#
 
use strict;
 
if (! $ARGV[0]) { 
  print "\n\t*** Enter the file to edit as first arg ***\n\n";
  exit(1);
}
 
my $file="$ARGV[0]";
my $status="0";
 
open IN, "< $file" or die "Cannot open: $!";
open OUT, "> $file~" or die "Cannot open: $!";
 
while (<IN>) {
  if ( $_ =~ m/^TT/ ) {
    $_ =~ s/(^TT)(.*)/====== \u$2 ======/;
  } 
 
  if ( $_ =~ m/^ *\*[^*]/ ) {
    $_ =~ s/(^ *\*)(.*)/  *\*\*__$2__\*\*/;
  } 
 
  if ( $_ =~ m/(^CC|^<code>)/ ) {
    if ( $status != "1" ){
      $_ =~ s/(^CC)/<code>/;
      $status="1";
    } elsif ($_ =~ m/(^CC|^<\/code)/ ){
        $_ =~ s/(^CC)/<\/code>/;
        $status="0";
      } 
  }
 
  if ( $_ !~ m/(^$|^ *\*|^ *=|\\\\$|<\/code>)/  && $status != "1") {
        $_ =~ s/( *\n)/\\\\\n/;
  }
 
  print OUT $_;
}
 
close IN;
close OUT;
rename "$file~", "$file" or die "Cannot rename: $!";
 
# end of story


 
about.txt · Last modified: 2010/02/10 13:45 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki