From 90feb1b23fff5bb3536542f284c6f77af3f4dc3b Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 23 Sep 2013 00:30:00 +0200 Subject: Initial commit --- README.org | 1 + org.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 README.org create mode 100755 org.pm diff --git a/README.org b/README.org new file mode 100644 index 0000000..fba71fc --- /dev/null +++ b/README.org @@ -0,0 +1 @@ +Use Emacs org-mode as markup. diff --git a/org.pm b/org.pm new file mode 100755 index 0000000..0d19177 --- /dev/null +++ b/org.pm @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# org-mode markup +# based on the WikiCreole plugin. +package IkiWiki::Plugin::org; + +use warnings; +use strict; +use IkiWiki 3.00; + +sub import { + hook(type => "getsetup", id => "org", call => \&getsetup); + hook(type => "htmlize", id => "org", call => \&htmlize); +} + +sub getsetup { + return plugin => { + safe => 0, + rebuild => 1, # format plugin + section => "format", + }, +} + +sub htmlize (@) { + my %params=@_; + my $content = $params{content}; + + print($params{page}); + + open(my $file, ">test.org") || die("Couldn't open test.org: $!"); + print $file $content; + close($file); + `emacs -batch -L ~/.emacs.d/vendor-lisp/org/lisp -L ~/.emacs.d/vendor-lisp/org/contrib/lisp -visit test.org -eval "(setq org-html-htmlize-output-type 'css)" -eval "(org-html-export-to-html nil nil nil t)"`; + open($file, "test.html") || die("Couldn't open test.html: $!"); + my @lines=<$file>; + close($file); + + unlink "test.org"; + unlink "test.html"; + + return join('', @lines); +} + +1 -- cgit v1.2.3-54-g00ecf