Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

schwern
  (email not shown publicly)
http://www.pobox.com/~schwern/
AOL IM: MichaelSchwern (Add Buddy, Send Message)
Yahoo! ID: schwern (Add User, Send Message)
Jabber: schwern@gmail.com

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Friday August 22, 2003
08:06 PM

Command line kwiki

[ #14275 ]

I'm writing some perl.com articles (Yes, Simon, I'm really writing them!) using the Kwiki format, because its so damned comfortable to write in (do ya hear me Slash?). But I hate editing in web pages (such as this one) though Safari makes it a bit nicer by providing some basic emacs functionality.

So Brian Ingerson gave me a little snippet so I could take a kwiki file and spit out HTML. I've made a little command line tool out of it:

#!/usr/bin/perl -w

my $File = shift;
my $FH = *STDIN;
if( defined $File ) {
    open(FILE, $File) || die "Can't open $File: $!";
    $FH = \*FILE;
}

use CGI::Kwiki;

my $driver = CGI::Kwiki::load_driver();
$driver->load_class('formatter');
{
    local $/;
    print $driver->formatter->process(<$FH>);
}

I write in article.kwiki and then run kwik article.kwiki > article.html. Ta da.

I've written a little Makefile for my articles.

NAME  = article
KWIKI = $(NAME).kwiki
HTML  = $(NAME).html

all:  htmlify

htmlify:  $(KWIKI)
        kwik $(KWIKI) > $(HTML)

You don't need a config.yaml, but since I needed a few special formatting rules and had to override CGI::Kwiki::Formatter to do this, I just put a config.yaml in the article directory. Kwiki will read its config file from the directory its run.

What a neat little tool.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Oh wait! You can [perl.org]! The method shown in that article should also work for vi. Happy huntin'.
  • Your makefile doesn't have to be nearly that tricky. Here's a minimal (GNUmake-specific) version that converts *.kwiki to *.html, and optionally converts a preset-list of files when necessary:
    OUTPUTS=article.html

    all: $(OUTPUTS)

    %.html: %.kwiki
            kwik $< > $@
    Just type make and all of the right things happen. :-)
  • m writing some perl.com articles ... using the Kwiki format, because its so damned comfortable to write in (do ya hear me Slash?).

    Not to sound like a grump ... but no, I don't, as I have no idea what you're talking about. Really.
    • Kwiki as a format for writing journal entries and the like. Manually writing HTML causes bad breath and herpes.
      • I know nothing about the Kwiki format, but I *do* know that you don't need to use HTML on Slash for most things. Select the "Plain Old Text" format and you don't need to use P and BR tags. To HREF-ize a URL just use <URL:http://use.perl.org/> to get http://use.perl.org/ [perl.org]. To do code blocks, use the ECODE tag. There are other shortcuts here and there.