aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm12
-rw-r--r--IkiWiki/Plugin/mdwn.pm36
-rw-r--r--IkiWiki/Render.pm18
-rw-r--r--basewiki/markdown.mdwn2
-rw-r--r--debian/changelog4
-rw-r--r--doc/features.mdwn11
-rw-r--r--doc/index.mdwn4
-rw-r--r--doc/plugins.mdwn2
-rw-r--r--doc/plugins/mdwn.mdwn3
-rw-r--r--doc/plugins/write.mdwn12
-rw-r--r--doc/usage.mdwn3
-rwxr-xr-xt/crazy-badass-perl-bug.t4
-rwxr-xr-xt/htmlize.t6
13 files changed, 78 insertions, 39 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 7be1c7f58..39ceec04e 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -42,7 +42,7 @@ sub defaultconfig () { #{{{
setup => undef,
adminuser => undef,
adminemail => undef,
- plugin => [qw{inline htmlscrubber}],
+ plugin => [qw{mdwn inline htmlscrubber}],
timeformat => '%c',
} #}}}
@@ -123,12 +123,10 @@ sub dirname ($) { #{{{
sub pagetype ($) { #{{{
my $page=shift;
- if ($page =~ /\.mdwn$/) {
- return ".mdwn";
- }
- else {
- return "unknown";
+ if ($page =~ /\.(.*)$/) {
+ return $1 if exists $hooks{htmlize}{$1};
}
+ return "unknown";
} #}}}
sub pagename ($) { #{{{
@@ -136,7 +134,7 @@ sub pagename ($) { #{{{
my $type=pagetype($file);
my $page=$file;
- $page=~s/\Q$type\E*$// unless $type eq 'unknown';
+ $page=~s/\Q.$type\E*$// unless $type eq 'unknown';
return $page;
} #}}}
diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm
new file mode 100644
index 000000000..a344de067
--- /dev/null
+++ b/IkiWiki/Plugin/mdwn.pm
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+# Markdown markup language
+package IkiWiki::Plugin::mdwn;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+sub import { #{{{
+ IkiWiki::hook(type => "htmlize", id => "mdwn", call => \&htmlize);
+} # }}}
+
+sub htmlize ($) { #{{{
+ my $content = shift;
+
+ if (! $INC{"/usr/bin/markdown"}) {
+ # Note: a proper perl module is available in Debian
+ # for markdown, but not upstream yet.
+ no warnings 'once';
+ $blosxom::version="is a proper perl module too much to ask?";
+ use warnings 'all';
+ do "/usr/bin/markdown";
+ require Encode;
+ }
+
+ # Workaround for perl bug (#376329)
+ $content=Encode::encode_utf8($content);
+ $content=Encode::encode_utf8($content);
+ $content=Markdown::Markdown($content);
+ $content=Encode::decode_utf8($content);
+ $content=Encode::decode_utf8($content);
+
+ return $content;
+} # }}}
+
+1
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index ac8f03937..8a4fb89eb 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -25,22 +25,8 @@ sub htmlize ($$) { #{{{
my $type=shift;
my $content=shift;
- if (! $INC{"/usr/bin/markdown"}) {
- # Note: a proper perl module is available in Debian
- # for markdown, but not upstream yet.
- no warnings 'once';
- $blosxom::version="is a proper perl module too much to ask?";
- use warnings 'all';
- do "/usr/bin/markdown";
- }
-
- if ($type eq '.mdwn') {
- # Workaround for perl bug (#376329)
- $content=Encode::encode_utf8($content);
- $content=Encode::encode_utf8($content);
- $content=Markdown::Markdown($content);
- $content=Encode::decode_utf8($content);
- $content=Encode::decode_utf8($content);
+ if (exists $hooks{htmlize}{$type}) {
+ $content=$hooks{htmlize}{$type}{call}->($content);
}
else {
error("htmlization of $type not supported");
diff --git a/basewiki/markdown.mdwn b/basewiki/markdown.mdwn
index 57fb259f8..317a17db9 100644
--- a/basewiki/markdown.mdwn
+++ b/basewiki/markdown.mdwn
@@ -1,6 +1,6 @@
[Markdown](http://daringfireball.net/projects/markdown/)
is a minimal markup language that resembles plain text as used in
-email messages. It is the markup language used by this wiki.
+email messages. It is the markup language used by this wiki by default.
For documentation about the markdown syntax, see [[HelpOnFormatting]] and
[Markdown: syntax](http://daringfireball.net/projects/markdown/syntax).
diff --git a/debian/changelog b/debian/changelog
index 082ab418f..1fafe4168 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -27,8 +27,10 @@ ikiwiki (1.8) UNRELEASED; urgency=low
This allows adding or removing plugins w/o overriding the whole list of
default plugins, which makes it easier to upgrade when new default plugins
are added.
+ * Support htmlize plugins and make mdwn one such plugin, which is enabled by
+ default (of course!). Based on a patch by Faidon Liambotis.
- -- Joey Hess <joeyh@debian.org> Mon, 3 Jul 2006 16:57:37 -0400
+ -- Joey Hess <joeyh@debian.org> Mon, 3 Jul 2006 18:06:49 -0400
ikiwiki (1.7) unstable; urgency=low
diff --git a/doc/features.mdwn b/doc/features.mdwn
index f116e00e3..0992130e5 100644
--- a/doc/features.mdwn
+++ b/doc/features.mdwn
@@ -26,6 +26,9 @@ Some of ikiwiki's features:
provided by ikiwiki aside from regular markdown is the [[WikiLink]] and
[[PreprocessorDirective]]
+ If you prefer to use some other markup language, ikiwiki allows others to
+ be added by [[plugins]].
+
* support for other file types
ikiwiki also supports files of any other type, including plain text,
@@ -120,10 +123,10 @@ Some of ikiwiki's features:
* [[Plugins]]
Plugins can be used to add additional features to ikiwiki. The interface
- is quite flexible, allowing plugins to register
- [[PreProcessorDirective]]s, hook into [[CGI]] mode, and more. Ikiwiki's
- backend RCS support is also pluggable, so support for new revision
- control systems can be added to ikiwiki.
+ is quite flexible, allowing plugins to implement additional markup
+ languages, register [[PreProcessorDirective]]s, hook into [[CGI]] mode,
+ and more. Ikiwiki's backend RCS support is also pluggable, so support for
+ new revision control systems can be added to ikiwiki.
* [[todo/utf8]]
diff --git a/doc/index.mdwn b/doc/index.mdwn
index c247cf744..3191d1c24 100644
--- a/doc/index.mdwn
+++ b/doc/index.mdwn
@@ -1,8 +1,8 @@
[[ikiwiki_logo|logo/ikiwiki.png]]
ikiwiki is a **wiki compiler**. It converts wiki pages
into html pages suitable for publishing on a website. Unlike a traditional
-wiki, ikiwiki does not have its own means of storing page history or its own
-markup language. Instead it can use [[Subversion]] (or [[Git]]) and [[MarkDown]].
+wiki, ikiwiki does not have its own means of storing page history.
+Instead it can use [[Subversion]] (or [[Git]]).
* [[News]] is a blog (built using ikiwiki) of news items about ikiwiki. It's the best way to find out when there's a new version to [[Download]].
diff --git a/doc/plugins.mdwn b/doc/plugins.mdwn
index 05b661f2b..d79a3bd3b 100644
--- a/doc/plugins.mdwn
+++ b/doc/plugins.mdwn
@@ -1,7 +1,7 @@
There's documentation if you want to [[write]] your own plugins, or you can
install and use plugins contributed by others.
-The [[inline]] and [[htmlscrubber]] plugins are enabled by default.
+The [[mdwn]], [[inline]], and [[htmlscrubber]] plugins are enabled by default.
To enable other plugins, use the `--plugin` switch described in [[usage]],
or the equivalent `add_plugins` line in [[ikiwiki.setup]].
diff --git a/doc/plugins/mdwn.mdwn b/doc/plugins/mdwn.mdwn
new file mode 100644
index 000000000..d1b1254bf
--- /dev/null
+++ b/doc/plugins/mdwn.mdwn
@@ -0,0 +1,3 @@
+This plugin, which is enabled by default, lets ikwiki convert files with
+names ending in ".mwdn" to html. It uses the [[markdown]] minimal markup
+language.
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 515c4d90d..5be90efdf 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -55,7 +55,8 @@ Note that if the [[htmlscrubber]] is enabled, html in
[[PreProcessorDirective]] output is sanitised, which may limit what your
plugin can do. Also, the rest of the page content is not in html format at
preprocessor time. Text output by a preprocessor directive will be passed
-through markdown along with the rest of the page.
+through markdown (or whatever engine is used to htmlize the page) along
+with the rest of the page.
# Other types of hooks
@@ -79,6 +80,15 @@ Runs on the raw source of a page, before anything else touches it, and can
make arbitrary changes. The function is passed named parameters `page` and
`content` and should return the filtered content.
+## htmlize
+
+ IkiWiki::hook(type => "htmlize", id => "ext", call => \&filter);
+
+Runs on the raw source of a page and turns it into html. The id parameter
+specifies the filename extension that a file must have to be htmlized using
+this plugin. This is how you can add support for new and exciting markup
+languages to ikiwiki.
+
## pagetemplate
IkiWiki::hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
diff --git a/doc/usage.mdwn b/doc/usage.mdwn
index deb94e415..6ff71056f 100644
--- a/doc/usage.mdwn
+++ b/doc/usage.mdwn
@@ -11,7 +11,8 @@ ikiwiki --setup configfile
# DESCRIPTION
`ikiwiki` is a wiki compiler. It builds static html pages for a wiki, from
-`source` in the [[MarkDown]] language, and writes it out to `destination`.
+`source` in the [[MarkDown]] language (or others), and writes it out to
+`destination`.
Note that most options can be shortened to single letters, and boolean
flags such as --verbose can be negated with --no-verbose.
diff --git a/t/crazy-badass-perl-bug.t b/t/crazy-badass-perl-bug.t
index 69e9731d8..f54f27c4b 100755
--- a/t/crazy-badass-perl-bug.t
+++ b/t/crazy-badass-perl-bug.t
@@ -14,6 +14,6 @@ BEGIN { use_ok("IkiWiki::Render"); }
%IkiWiki::config=IkiWiki::defaultconfig();
$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null";
IkiWiki::checkconfig();
-ok(IkiWiki::htmlize(".mdwn", IkiWiki::readfile("t/test1.mdwn")));
-ok(IkiWiki::htmlize(".mdwn", IkiWiki::readfile("t/test3.mdwn")),
+ok(IkiWiki::htmlize("mdwn", IkiWiki::readfile("t/test1.mdwn")));
+ok(IkiWiki::htmlize("mdwn", IkiWiki::readfile("t/test3.mdwn")),
"wtf?") for 1..100;
diff --git a/t/htmlize.t b/t/htmlize.t
index 742b6e2bc..687eb03a8 100755
--- a/t/htmlize.t
+++ b/t/htmlize.t
@@ -12,10 +12,10 @@ BEGIN { use_ok("IkiWiki::Render"); }
$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null";
IkiWiki::checkconfig();
-is(IkiWiki::htmlize(".mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n",
+is(IkiWiki::htmlize("mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n",
"basic");
-is(IkiWiki::htmlize(".mdwn", IkiWiki::readfile("t/test1.mdwn")),
+is(IkiWiki::htmlize("mdwn", IkiWiki::readfile("t/test1.mdwn")),
Encode::decode_utf8(qq{<p><img src="../images/o.jpg" alt="o" title="&oacute;" />\nóóóóó</p>\n}),
"utf8; bug #373203");
-ok(IkiWiki::htmlize(".mdwn", IkiWiki::readfile("t/test2.mdwn")),
+ok(IkiWiki::htmlize("mdwn", IkiWiki::readfile("t/test2.mdwn")),
"this file crashes markdown if it's fed in as decoded utf-8");