#!/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 { #{{{ hook(type => "htmlize", id => "rst", call => \&htmlize); } # }}} sub htmlize (@) { #{{{ my %params=@_; my $content=$params{content}; my $pid; my $sigpipe=0; $SIG{PIPE}=sub { $sigpipe=1 }; $pid=open2(*IN, *OUT, "python", "-c", $pyCmnd); # open2 doesn't respect "use open ':utf8'" binmode (IN, ':utf8'); binmode (OUT, ':utf8'); print OUT $content; close OUT; local $/ = undef; my $ret=; close IN; waitpid $pid, 0; return $content if $sigpipe; $SIG{PIPE}="DEFAULT"; return $ret; } # }}} 1 class='right' method='get' action='/notmuch/log/tags/f5/f6/slrnqpbt36.3tj.curty@einstein.electron.org'>
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2023-06-27 09:35:08 +0200
committerJonas Smedegaard <dr@jones.dk>2023-06-27 09:35:08 +0200
commitfd54908da2b05c526dd3bee9b6dcd093214a220d (patch)
treec69c845069c99d1d01044f6fafda7c08433329c6 /tags/f5/f6/slrnqpbt36.3tj.curty@einstein.electron.org
parentba46132213560cf3335d53560d519c0ec0190da2 (diff)
Diffstat (limited to 'tags/f5/f6/slrnqpbt36.3tj.curty@einstein.electron.org')
-rw-r--r--tags/f5/f6/slrnqpbt36.3tj.curty@einstein.electron.org/debian0
-rw-r--r--tags/f5/f6/slrnqpbt36.3tj.curty@einstein.electron.org/unread0
2 files changed, 0 insertions, 0 deletions