Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

  (email not shown publicly)
AOL IM: MichaelSchwern (Add Buddy, Send Message)

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 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();
    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.
More | Login | Reply
Loading... please wait.
  • Oh wait! You can []! 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:

    all: $(OUTPUTS)

    %.html: %.kwiki
            kwik $< > $@
    Just type make and all of the right things happen. :-)
  • m writing some 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:> to get []. To do code blocks, use the ECODE tag. There are other shortcuts here and there.