From 63edea27bc71c3bdf1837f994fb7effdd93fb2dd Mon Sep 17 00:00:00 2001 From: joey Date: Sat, 19 Aug 2006 05:05:02 +0000 Subject: [PATCH 1/1] * 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. --- IkiWiki/Plugin/map.pm | 2 +- IkiWiki/Plugin/pagestats.pm | 2 +- IkiWiki/Plugin/rst.pm | 69 +++++++++++++++++++++++++++++++++++++ debian/changelog | 6 +++- doc/ikiwiki.setup | 2 +- doc/patchqueue/rst.mdwn | 66 ----------------------------------- doc/plugins/htmltidy.mdwn | 1 + doc/plugins/map.mdwn | 1 + doc/plugins/pagestats.mdwn | 1 + doc/plugins/polygen.mdwn | 1 + doc/plugins/rst.mdwn | 24 +++++++++++++ doc/plugins/sidebar.mdwn | 1 + doc/roadmap.mdwn | 2 +- 13 files changed, 107 insertions(+), 71 deletions(-) create mode 100644 IkiWiki/Plugin/rst.pm delete mode 100644 doc/patchqueue/rst.mdwn create mode 100644 doc/plugins/rst.mdwn diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 070f49415..0ae5c1002 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -2,7 +2,7 @@ # # Produce a hyerarchical map of links. # -# By Alessandro Dotti Contra +# by Alessandro Dotti Contra # # Revision: 0.2 package IkiWiki::Plugin::map; diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index de559e2c5..8ce563fc5 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -7,7 +7,7 @@ # (default) # table: produces a table with the number of backlinks for each page # -# By Enrico Zini. +# by Enrico Zini package IkiWiki::Plugin::pagestats; use warnings; diff --git a/IkiWiki/Plugin/rst.pm b/IkiWiki/Plugin/rst.pm new file mode 100644 index 000000000..6bf11fe36 --- /dev/null +++ b/IkiWiki/Plugin/rst.pm @@ -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 + +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('')+6:html.find('')].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 ; +} # }}} + +1 diff --git a/debian/changelog b/debian/changelog index 779147086..61379c5fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,8 +12,12 @@ ikiwiki (1.21) UNRELEASED; urgency=low * Add a map plugin contributed by Alessandro Dotti Contra. * Add otl format plugin, which handles files as created by vimoutliner. * 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 Fri, 18 Aug 2006 22:54:08 -0400 + -- Joey Hess Sat, 19 Aug 2006 00:56:32 -0400 ikiwiki (1.20) unstable; urgency=low diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 678dece23..bf1aa3703 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -81,7 +81,7 @@ use IkiWiki::Setup::Standard { # To add plugins, list them here. #add_plugins => [qw{meta tag pagecount brokenlinks search smiley # wikitext camelcase pagestats htmltidy fortune - # sidebar map}], + # sidebar map rst}], # If you want to disable any of the default plugins, list them here. #disable_plugins => [qw{inline htmlscrubber}], } diff --git a/doc/patchqueue/rst.mdwn b/doc/patchqueue/rst.mdwn deleted file mode 100644 index c2790990e..000000000 --- a/doc/patchqueue/rst.mdwn +++ /dev/null @@ -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 - - 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('')+6:html.find('')].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 ; - } # }}} - - 1 diff --git a/doc/plugins/htmltidy.mdwn b/doc/plugins/htmltidy.mdwn index f6f6e0c17..9da9c4d98 100644 --- a/doc/plugins/htmltidy.mdwn +++ b/doc/plugins/htmltidy.mdwn @@ -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. This plugin is included in ikiwiki, but is not enabled by default. +It was contributed by Faidon Liambotis. [[tag type/html]] diff --git a/doc/plugins/map.mdwn b/doc/plugins/map.mdwn index 40e284256..cd2ef1bc5 100644 --- a/doc/plugins/map.mdwn +++ b/doc/plugins/map.mdwn @@ -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 !*/*/*"` 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 of this wiki: diff --git a/doc/plugins/pagestats.mdwn b/doc/plugins/pagestats.mdwn index a9f3bdbdb..93e9f5694 100644 --- a/doc/plugins/pagestats.mdwn +++ b/doc/plugins/pagestats.mdwn @@ -11,5 +11,6 @@ And here's how to create a table of all the pages on the wiki: \[[pagestats style="table"]] This plugin is included in ikiwiki, but is not enabled by default. +It was contributed by Enrico Zini [[tag type/meta type/tags]] diff --git a/doc/plugins/polygen.mdwn b/doc/plugins/polygen.mdwn index 85b05e102..d04708e2a 100644 --- a/doc/plugins/polygen.mdwn +++ b/doc/plugins/polygen.mdwn @@ -7,6 +7,7 @@ It's also possible to specify a starting nonterminal for the grammar by including `symbol="text"` in the directive. This plugin is included in ikiwiki, but not enabled by default. +It was contributed by Enrico Zini. ---- diff --git a/doc/plugins/rst.mdwn b/doc/plugins/rst.mdwn new file mode 100644 index 000000000..0f0d6f96c --- /dev/null +++ b/doc/plugins/rst.mdwn @@ -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]] diff --git a/doc/plugins/sidebar.mdwn b/doc/plugins/sidebar.mdwn index f38e56817..8ab416f6f 100644 --- a/doc/plugins/sidebar.mdwn +++ b/doc/plugins/sidebar.mdwn @@ -12,5 +12,6 @@ you can create a sidebar page that is completely empty. This will turn off the sidebar altogether. This plugin is included in ikiwiki, but is not enabled by default. +It was contributed by Tuomo Valkonen. [[tag type/chrome]] diff --git a/doc/roadmap.mdwn b/doc/roadmap.mdwn index 4ab0a7e59..a645877fb 100644 --- a/doc/roadmap.mdwn +++ b/doc/roadmap.mdwn @@ -25,6 +25,6 @@ Released 29 April 2006. quickly grow to support them all.. See [[about_rcs_backends]] _(status: supports git in tree)_ * 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 severe-to-moderate known [[security]] issues. -- 2.39.5