ikiwiki/doc/patchqueue/format_escape.mdwn

76 lines
3.2 KiB
Markdown

Since some preprocessor directives insert raw HTML, it would be good to
specify, per-format, how to pass HTML so that it goes through the format
OK. With Markdown we cross our fingers; with reST we use the "raw"
directive.
I added an extra named parameter to the htmlize hook, which feels sort of
wrong, since none of the other hooks take parameters. Let me know what
you think. --Ethan
Seems fairly reasonable, actually. Shouldn't the `$type` come from `$page`
instead of `$destpage` though? Only other obvious change is to make the
escape parameter optional, and only call it if set. --[[Joey]]
> I couldn't figure out what to make it from, but thinking it through,
> yeah, it should be $page. Revised patch follows. --Ethan
<pre>
diff -urNX ignorepats ikiwiki/IkiWiki/Plugin/rst.pm ikidev/IkiWiki/Plugin/rst.pm
--- ikiwiki/IkiWiki/Plugin/rst.pm 2006-09-25 14:30:40.000000000 -0700
+++ ikidev/IkiWiki/Plugin/rst.pm 2007-02-27 22:44:11.040042000 -0800
@@ -25,13 +25,19 @@
html = publish_string(stdin.read(), writer_name='html',
settings_overrides = { 'halt_level': 6,
'file_insertion_enabled': 0,
- 'raw_enabled': 0 }
+ 'raw_enabled': 1 }
);
print html[html.find('<body>')+6:html.find('</body>')].strip();
";
sub import { #{{{
- hook(type => "htmlize", id => "rst", call => \&htmlize);
+ hook(type => "htmlize", id => "rst", call => \&htmlize, escape => \&escape);
+} # }}}
+
+sub escape ($) { #{{{
+ my $html = shift;
+ $html =~ s/^/ /mg;
+ return ".. raw:: html\n\n".$html;
} # }}}
sub htmlize (@) { #{{{
diff -urNX ignorepats ikiwiki/IkiWiki/Plugin/shortcut.pm ikidev/IkiWiki/Plugin/shortcut.pm
--- ikiwiki/IkiWiki/Plugin/shortcut.pm 2007-02-15 00:38:48.000000000 -0800
+++ ikidev/IkiWiki/Plugin/shortcut.pm 2007-02-27 22:09:31.536088000 -0800
@@ -13,6 +13,7 @@
sub checkconfig () { #{{{
# Preprocess the shortcuts page to get all the available shortcuts
# defined before other pages are rendered.
+ $pagesources{"shortcuts"} = "shortcuts.mdwn";
IkiWiki::preprocess("shortcuts", "shortcuts",
readfile(srcfile("shortcuts.mdwn")));
} # }}}
diff -urNX ignorepats ikiwiki/IkiWiki.pm ikidev/IkiWiki.pm
--- ikiwiki/IkiWiki.pm 2007-02-25 15:01:27.211170000 -0800
+++ ikidev/IkiWiki.pm 2007-03-01 18:20:39.910925000 -0800
@@ -580,6 +577,17 @@
destpage => $destpage,
);
$preprocessing{$page}--;
+ if ($ret =~ /[<>]/){
+ if ($pagesources{$page}) {
+ my $type=pagetype($pagesources{$page});
+ if ($hooks{htmlize}{$type}{escape}) {
+ $ret = $hooks{htmlize}{$type}{escape}->(
+ $ret,
+ );
+ }
+ }
+ }
+
return $ret;
}
else {
</pre>