]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/plugins/contrib/siterel2pagerel.mdwn
Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki.git] / doc / plugins / contrib / siterel2pagerel.mdwn
index 7bdeea965dc1830a5f35cfd4c957aca7821607bb..9b09657bf0540aabc5ab4e5c8e3fcd575cde3a4a 100644 (file)
@@ -1,4 +1,9 @@
-This is a simple plugin to convert all site-relative links to page-relative links (converts /foo into ../../../foo or similar). It works as a postprocessing filter, allowing it to work on mdwn, wiki, html, rst and any other format that produces html. The code is available here:
+[[!template id=plugin name=siterel2pagerel author="[[PaulWise]]"]]
+
+This is a simple plugin to convert all site-relative links to page-relative
+links (converts /foo into ../../../foo or similar). It works as a
+postprocessing filter, allowing it to work on mdwn, wiki, html, rst and any
+other format that produces html. The code is available here:
 
        #!/usr/bin/perl
        # quick HTML siterel2pagerel link hack by Paul Wise
@@ -8,11 +13,11 @@ This is a simple plugin to convert all site-relative links to page-relative link
        use strict;
        use IkiWiki 2.00;
 
-       sub import { #{{{
+       sub import {
                hook(type => "sanitize", id => "siterel2pagerel", call => \&siterel2pagerel);
-       } # }}}
+       }
 
-       sub siterel2pagerel (@) { #{{{
+       sub siterel2pagerel (@) {
                my %params=@_;
                my $baseurl=IkiWiki::baseurl($params{page});
                my $content=$params{content};
@@ -20,6 +25,6 @@ This is a simple plugin to convert all site-relative links to page-relative link
                $content=~s/(<img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"\/([^"]*)"/$1 src="$baseurl$2"/mig;
                # FIXME: do <script and everything else that can have URLs in it
                return $content;
-       } # }}}
+       }
 
        1