* Add first draft at a Restructured Text (rst) plugin, by Sergio

Talens-Oliag. Note that this has many known issues -- see the caveats on
  the plugin's page.
* Credit everyone who wrote a plugin on the plugins' wiki pages.
master
joey 2006-08-19 05:05:02 +00:00
parent 02e4b42034
commit 63edea27bc
13 changed files with 107 additions and 71 deletions

View File

@ -2,7 +2,7 @@
# #
# Produce a hyerarchical map of links. # Produce a hyerarchical map of links.
# #
# By Alessandro Dotti Contra <alessandro@hyboria.org> # by Alessandro Dotti Contra <alessandro@hyboria.org>
# #
# Revision: 0.2 # Revision: 0.2
package IkiWiki::Plugin::map; package IkiWiki::Plugin::map;

View File

@ -7,7 +7,7 @@
# (default) # (default)
# table: produces a table with the number of backlinks for each page # table: produces a table with the number of backlinks for each page
# #
# By Enrico Zini. # by Enrico Zini
package IkiWiki::Plugin::pagestats; package IkiWiki::Plugin::pagestats;
use warnings; use warnings;

View File

@ -0,0 +1,69 @@
#!/usr/bin/perl
# Very simple reStructuredText processor.
#
# This plugin calls python and requires python-docutils to transform the text
# into html.
#
# Its main problem is that it does not support ikiwiki's WikiLinks nor
# Preprocessor Directives.
#
# Probably Wikilinks and Preprocessor Directives should support a list of
# extensions to process (i.e. the linkify function could be transformed into
# reStructuredText instead of HTML using a hook on rst.py instead of the
# current linkify function)
#
# by Sergio Talens-Oliag <sto@debian.org>
package IkiWiki::Plugin::rst;
use warnings;
use strict;
use IkiWiki;
use IPC::Open2;
# Simple python script, maybe it should be implemented using an external script.
# The settings_overrides are given to avoid potential security risks when
# reading external files or if raw html is included on rst pages.
my $pyCmnd = "
from docutils.core import publish_string;
from sys import stdin;
html = publish_string(stdin.read(), writer_name='html',
settings_overrides = { 'halt_level': 6,
'file_insertion_enabled': 0,
'raw_enabled': 0 }
);
print html[html.find('<body>')+6:html.find('</body>')].strip();
";
sub import { #{{{
IkiWiki::hook(type => "htmlize", id => "rst", call => \&htmlize);
} # }}}
sub htmlize ($) { #{{{
my $content=shift;
my $tries=10;
while (1) {
eval {
# Try to call python and run our command
open2(*IN, *OUT, "python", "-c", $pyCmnd)
or return $content;
};
last unless $@;
$tries--;
if ($tries < 1) {
IkiWiki::debug("failed to run python to convert rst: $@");
return $content;
}
}
# open2 doesn't respect "use open ':utf8'"
binmode (IN, ':utf8');
binmode (OUT, ':utf8');
print OUT $content;
close OUT;
local $/ = undef;
return <IN>;
} # }}}
1

6
debian/changelog vendored
View File

@ -12,8 +12,12 @@ ikiwiki (1.21) UNRELEASED; urgency=low
* Add a map plugin contributed by Alessandro Dotti Contra. * Add a map plugin contributed by Alessandro Dotti Contra.
* Add otl format plugin, which handles files as created by vimoutliner. * Add otl format plugin, which handles files as created by vimoutliner.
* Fix ikiwiki-mass-rebuild to work in the way the postinst uses it. * Fix ikiwiki-mass-rebuild to work in the way the postinst uses it.
* Add first draft at a Restructured Text (rst) plugin, by Sergio
Talens-Oliag. Note that this has many known issues -- see the caveats on
the plugin's page.
* Credit everyone who wrote a plugin on the plugins' wiki pages.
-- Joey Hess <joeyh@debian.org> Fri, 18 Aug 2006 22:54:08 -0400 -- Joey Hess <joeyh@debian.org> Sat, 19 Aug 2006 00:56:32 -0400
ikiwiki (1.20) unstable; urgency=low ikiwiki (1.20) unstable; urgency=low

View File

@ -81,7 +81,7 @@ use IkiWiki::Setup::Standard {
# To add plugins, list them here. # To add plugins, list them here.
#add_plugins => [qw{meta tag pagecount brokenlinks search smiley #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
# wikitext camelcase pagestats htmltidy fortune # wikitext camelcase pagestats htmltidy fortune
# sidebar map}], # sidebar map rst}],
# If you want to disable any of the default plugins, list them here. # If you want to disable any of the default plugins, list them here.
#disable_plugins => [qw{inline htmlscrubber}], #disable_plugins => [qw{inline htmlscrubber}],
} }

View File

@ -1,66 +0,0 @@
This is a whole lot better than nothing, but it's a shame it forks python
every page. Anyone want to get [this](http://search.cpan.org/~nodine/Text-Restructured-0.003016/) into Debian and use it instead?
--[[Joey]]
Actually, if someone adds support for it to ikiwiki, I would be glad to get
the package into Debian myself --[[Joey]]
#!/usr/bin/perl
# Very simple reStructuredText processor.
#
# This plugin calls python and requires python-docutils to transform the text
# into html.
#
# It's main problem is that it does not support ikiwiki's WikiLinks nor
# Preprocessor Directives (in fact the same problem applies to the current
# Wikitext processor, although in that case the output looks less worse ;)
#
# Probably Wikilinks and Preprocessor Directives should support a list of
# extensions to process (i.e. the linkify function could be transformed into
# reStructuredText instead of HTML using a hook on rst.py instead of the
# current linkify function)
#
# by Sergio Talens-Oliag <sto@debian.org>
package IkiWiki::Plugin::rst;
use warnings;
use strict;
use IkiWiki;
use IPC::Open2;
# Simple python script, maybe it should be implemented using an external script.
# The settings_overrides are given to avoid potential security risks when
# reading external files or if raw html is included on rst pages.
my $pyCmnd = "
from docutils.core import publish_string;
from sys import stdin;
html = publish_string(stdin.read(), writer_name='html',
settings_overrides = { 'halt_level': 6,
'file_insertion_enabled': 0,
'raw_enabled': 0 }
);
print html[html.find('<body>')+6:html.find('</body>')].strip();
";
sub import { #{{{
IkiWiki::hook(type => "htmlize", id => "rst", call => \&htmlize);
} # }}}
sub htmlize ($) { #{{{
my $content = shift;
# Try to call python and run our command
open2(*IN, *OUT, "python", "-c", "$pyCmnd") or return $content;
# open2 doesn't respect "use open ':utf8'"
binmode (IN, ':utf8');
binmode (OUT, ':utf8');
print OUT $content;
close OUT;
local $/ = undef;
return <IN>;
} # }}}
1

View File

@ -3,5 +3,6 @@ emitted by ikiwiki. Besides being nicely formatted, this helps ensure that
even if users enter suboptimal html, your wiki generates valid html. even if users enter suboptimal html, your wiki generates valid html.
This plugin is included in ikiwiki, but is not enabled by default. This plugin is included in ikiwiki, but is not enabled by default.
It was contributed by Faidon Liambotis.
[[tag type/html]] [[tag type/html]]

View File

@ -9,6 +9,7 @@ Hint: To limit the map to displaying pages less than a certian level deep,
use a [[PageSpec]] like this: `pages="* and !*/*/*"` use a [[PageSpec]] like this: `pages="* and !*/*/*"`
This plugin is included in ikiwiki, but is not enabled by default. This plugin is included in ikiwiki, but is not enabled by default.
It was contributed by Alessandro Dotti Contra.
If this plugin is enabled, here is a page map for the plugins section If this plugin is enabled, here is a page map for the plugins section
of this wiki: of this wiki:

View File

@ -11,5 +11,6 @@ And here's how to create a table of all the pages on the wiki:
\[[pagestats style="table"]] \[[pagestats style="table"]]
This plugin is included in ikiwiki, but is not enabled by default. This plugin is included in ikiwiki, but is not enabled by default.
It was contributed by Enrico Zini
[[tag type/meta type/tags]] [[tag type/meta type/tags]]

View File

@ -7,6 +7,7 @@ It's also possible to specify a starting nonterminal for the grammar by
including `symbol="text"` in the directive. including `symbol="text"` in the directive.
This plugin is included in ikiwiki, but not enabled by default. This plugin is included in ikiwiki, but not enabled by default.
It was contributed by Enrico Zini.
---- ----

View File

@ -0,0 +1,24 @@
This plugin lets ikwiki convert files with names ending in ".rst" to html.
It uses the [reStructuredText](http://docutils.sourceforge.net/rst.html)
markup syntax. You need to have the python-docutils module installed to use
it.
Note that this plugin does not interoperate very well with the rest of
ikiwiki. Limitations include:
* reStructuredText does not allow raw html to be inserted into
documents, but ikiwiki does so in many cases, including
[[WikiLinks|WikiLink]] and many
[[PreprocessorDirectives|PreprocessorDirective]].
* It's slow; it forks a copy of python for each page. While there is a
perl version of the reStructuredText processor, it is not being kept in
sync with the standard version, so is not used.
So while you may find this useful for importing old files into your wiki,
using this as your main markup language in ikiwiki isn't recommended at
this time.
This plugin is included in ikiwiki, but not enabled by default.
It was contributed by Sergio Talens-Oliag.
[[tag type/format]]

View File

@ -12,5 +12,6 @@ you can create a sidebar page that is completely empty. This will turn off
the sidebar altogether. the sidebar altogether.
This plugin is included in ikiwiki, but is not enabled by default. This plugin is included in ikiwiki, but is not enabled by default.
It was contributed by Tuomo Valkonen.
[[tag type/chrome]] [[tag type/chrome]]

View File

@ -25,6 +25,6 @@ Released 29 April 2006.
quickly grow to support them all.. See [[about_rcs_backends]] quickly grow to support them all.. See [[about_rcs_backends]]
_(status: supports git in tree)_ _(status: supports git in tree)_
* Support for one other markup language, probably restructured text. * Support for one other markup language, probably restructured text.
_(status: done, but need a few more in tree)_ _(status: done, but the rst plugin needs improvement)_
* No serious known [[bugs]] * No serious known [[bugs]]
* No severe-to-moderate known [[security]] issues. * No severe-to-moderate known [[security]] issues.