* Support htmlize plugins and make mdwn one such plugin, which is enabled by
default (of course!). Based on a patch by Faidon Liambotis.master
parent
7ea8df24b3
commit
6551c1e560
12
IkiWiki.pm
12
IkiWiki.pm
|
@ -42,7 +42,7 @@ sub defaultconfig () { #{{{
|
||||||
setup => undef,
|
setup => undef,
|
||||||
adminuser => undef,
|
adminuser => undef,
|
||||||
adminemail => undef,
|
adminemail => undef,
|
||||||
plugin => [qw{inline htmlscrubber}],
|
plugin => [qw{mdwn inline htmlscrubber}],
|
||||||
timeformat => '%c',
|
timeformat => '%c',
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
@ -123,12 +123,10 @@ sub dirname ($) { #{{{
|
||||||
sub pagetype ($) { #{{{
|
sub pagetype ($) { #{{{
|
||||||
my $page=shift;
|
my $page=shift;
|
||||||
|
|
||||||
if ($page =~ /\.mdwn$/) {
|
if ($page =~ /\.(.*)$/) {
|
||||||
return ".mdwn";
|
return $1 if exists $hooks{htmlize}{$1};
|
||||||
}
|
|
||||||
else {
|
|
||||||
return "unknown";
|
|
||||||
}
|
}
|
||||||
|
return "unknown";
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
sub pagename ($) { #{{{
|
sub pagename ($) { #{{{
|
||||||
|
@ -136,7 +134,7 @@ sub pagename ($) { #{{{
|
||||||
|
|
||||||
my $type=pagetype($file);
|
my $type=pagetype($file);
|
||||||
my $page=$file;
|
my $page=$file;
|
||||||
$page=~s/\Q$type\E*$// unless $type eq 'unknown';
|
$page=~s/\Q.$type\E*$// unless $type eq 'unknown';
|
||||||
return $page;
|
return $page;
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -25,22 +25,8 @@ sub htmlize ($$) { #{{{
|
||||||
my $type=shift;
|
my $type=shift;
|
||||||
my $content=shift;
|
my $content=shift;
|
||||||
|
|
||||||
if (! $INC{"/usr/bin/markdown"}) {
|
if (exists $hooks{htmlize}{$type}) {
|
||||||
# Note: a proper perl module is available in Debian
|
$content=$hooks{htmlize}{$type}{call}->($content);
|
||||||
# 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);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error("htmlization of $type not supported");
|
error("htmlization of $type not supported");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[Markdown](http://daringfireball.net/projects/markdown/)
|
[Markdown](http://daringfireball.net/projects/markdown/)
|
||||||
is a minimal markup language that resembles plain text as used in
|
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
|
For documentation about the markdown syntax, see [[HelpOnFormatting]] and
|
||||||
[Markdown: syntax](http://daringfireball.net/projects/markdown/syntax).
|
[Markdown: syntax](http://daringfireball.net/projects/markdown/syntax).
|
||||||
|
|
|
@ -27,8 +27,10 @@ ikiwiki (1.8) UNRELEASED; urgency=low
|
||||||
This allows adding or removing plugins w/o overriding the whole list of
|
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
|
default plugins, which makes it easier to upgrade when new default plugins
|
||||||
are added.
|
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
|
ikiwiki (1.7) unstable; urgency=low
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ Some of ikiwiki's features:
|
||||||
provided by ikiwiki aside from regular markdown is the [[WikiLink]] and
|
provided by ikiwiki aside from regular markdown is the [[WikiLink]] and
|
||||||
[[PreprocessorDirective]]
|
[[PreprocessorDirective]]
|
||||||
|
|
||||||
|
If you prefer to use some other markup language, ikiwiki allows others to
|
||||||
|
be added by [[plugins]].
|
||||||
|
|
||||||
* support for other file types
|
* support for other file types
|
||||||
|
|
||||||
ikiwiki also supports files of any other type, including plain text,
|
ikiwiki also supports files of any other type, including plain text,
|
||||||
|
@ -120,10 +123,10 @@ Some of ikiwiki's features:
|
||||||
* [[Plugins]]
|
* [[Plugins]]
|
||||||
|
|
||||||
Plugins can be used to add additional features to ikiwiki. The interface
|
Plugins can be used to add additional features to ikiwiki. The interface
|
||||||
is quite flexible, allowing plugins to register
|
is quite flexible, allowing plugins to implement additional markup
|
||||||
[[PreProcessorDirective]]s, hook into [[CGI]] mode, and more. Ikiwiki's
|
languages, register [[PreProcessorDirective]]s, hook into [[CGI]] mode,
|
||||||
backend RCS support is also pluggable, so support for new revision
|
and more. Ikiwiki's backend RCS support is also pluggable, so support for
|
||||||
control systems can be added to ikiwiki.
|
new revision control systems can be added to ikiwiki.
|
||||||
|
|
||||||
* [[todo/utf8]]
|
* [[todo/utf8]]
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[[ikiwiki_logo|logo/ikiwiki.png]]
|
[[ikiwiki_logo|logo/ikiwiki.png]]
|
||||||
ikiwiki is a **wiki compiler**. It converts wiki pages
|
ikiwiki is a **wiki compiler**. It converts wiki pages
|
||||||
into html pages suitable for publishing on a website. Unlike a traditional
|
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
|
wiki, ikiwiki does not have its own means of storing page history.
|
||||||
markup language. Instead it can use [[Subversion]] (or [[Git]]) and [[MarkDown]].
|
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]].
|
* [[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]].
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
There's documentation if you want to [[write]] your own plugins, or you can
|
There's documentation if you want to [[write]] your own plugins, or you can
|
||||||
install and use plugins contributed by others.
|
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]],
|
To enable other plugins, use the `--plugin` switch described in [[usage]],
|
||||||
or the equivalent `add_plugins` line in [[ikiwiki.setup]].
|
or the equivalent `add_plugins` line in [[ikiwiki.setup]].
|
||||||
|
|
|
@ -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.
|
|
@ -55,7 +55,8 @@ Note that if the [[htmlscrubber]] is enabled, html in
|
||||||
[[PreProcessorDirective]] output is sanitised, which may limit what your
|
[[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
|
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
|
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
|
# 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
|
make arbitrary changes. The function is passed named parameters `page` and
|
||||||
`content` and should return the filtered content.
|
`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
|
## pagetemplate
|
||||||
|
|
||||||
IkiWiki::hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
|
IkiWiki::hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
|
||||||
|
|
|
@ -11,7 +11,8 @@ ikiwiki --setup configfile
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
|
|
||||||
`ikiwiki` is a wiki compiler. It builds static html pages for a wiki, from
|
`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
|
Note that most options can be shortened to single letters, and boolean
|
||||||
flags such as --verbose can be negated with --no-verbose.
|
flags such as --verbose can be negated with --no-verbose.
|
||||||
|
|
|
@ -14,6 +14,6 @@ BEGIN { use_ok("IkiWiki::Render"); }
|
||||||
%IkiWiki::config=IkiWiki::defaultconfig();
|
%IkiWiki::config=IkiWiki::defaultconfig();
|
||||||
$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null";
|
$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null";
|
||||||
IkiWiki::checkconfig();
|
IkiWiki::checkconfig();
|
||||||
ok(IkiWiki::htmlize(".mdwn", IkiWiki::readfile("t/test1.mdwn")));
|
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/test3.mdwn")),
|
||||||
"wtf?") for 1..100;
|
"wtf?") for 1..100;
|
||||||
|
|
|
@ -12,10 +12,10 @@ BEGIN { use_ok("IkiWiki::Render"); }
|
||||||
$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null";
|
$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null";
|
||||||
IkiWiki::checkconfig();
|
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");
|
"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="ó" />\nóóóóó</p>\n}),
|
Encode::decode_utf8(qq{<p><img src="../images/o.jpg" alt="o" title="ó" />\nóóóóó</p>\n}),
|
||||||
"utf8; bug #373203");
|
"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");
|
"this file crashes markdown if it's fed in as decoded utf-8");
|
||||||
|
|
Loading…
Reference in New Issue