Command line kwiki

schwern on 2003-08-23T01:06:48

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.


If only you could post journals from emacs

jjohn on 2003-08-23T12:34:42

Oh wait! You can! The method shown in that article should also work for vi. Happy huntin'.

Easier than that

ziggy on 2003-08-25T20:42:06

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. :-)

Hearing

pudge on 2003-08-26T23:16:00

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.

Re:Hearing

schwern on 2003-08-31T08:27:18

Kwiki as a format for writing journal entries and the like. Manually writing HTML causes bad breath and herpes.

Re:Hearing

pudge on 2003-08-31T15:10:53

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/. To do code blocks, use the ECODE tag. There are other shortcuts here and there.