Bookkeeping.
[muse-el.git] / examples / ikiwiki / muse
blob266434b81832ea0e99cdb07e214bacb4f431b9e5
1 #!/usr/bin/perl
2 # Ikiwiki plugin for Emacs Muse.
3 # Author: Michael Olson
4 # License: GPLv2 or later
6 # In your ikiwiki.setup file, set the muse_init option to the location
7 # of the init file for Muse. Some examples provided in this directory
8 # are muse-init-simple.el and muse-init-project.el.
10 package IkiWiki::Plugin::muse;
12 use warnings;
13 use strict;
14 use IkiWiki 2.00;
15 use Encode;
16 use File::Temp;
18 sub import {
19 hook(type => "htmlize", id => "muse", call => \&htmlize);
22 sub htmlize (@) {
23 my %params=@_;
24 my $content = decode_utf8(encode_utf8($params{content}));
25 my $qname = $params{page};
26 $qname =~ s/"/\\"/g;
28 my ($fh, $filename) = File::Temp::tempfile();
29 print $fh $content;
30 close $fh;
31 my $qfile = $filename;
32 $qfile =~ s/"/\\"/g;
33 eval {
34 system qw( emacs -q --no-site-file -batch -l ),
35 $config{muse_init}, '--eval',
36 qq{(muse-ikiwiki-publish-file "$qfile" "$qname")};
38 open my $ifh, '<', $filename;
39 local $/;
40 $content = <$ifh>;
41 close $ifh;
44 unlink $filename;
45 return $content;
48 sub test {
49 print htmlize(content => "<example>\nHello\n</example>\n\nParagraph.\n",
50 page => "some_page.muse");