--- a/wiki.pl
+++ b/wiki.pl
@@ -9,6 +9,7 @@
 #    and The Original WikiWikiWeb  (C) Ward Cunningham
 #        <ward@c2.com> (code reused with permission)
 # Email and ThinLine options by Jim Mahoney <mahoney@marlboro.edu>
+# BodyOnly option by Christoph Berg <cb@df7cb.de>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -53,7 +54,7 @@ use vars qw(@RcDays @HtmlPairs @HtmlSing
   @IsbnNames @IsbnPre @IsbnPost $EmailFile $FavIcon $RssDays $UserHeader
   $UserBody $StartUID $ParseParas $AuthorFooter $UseUpload $AllUpload
   $UploadDir $UploadUrl $LimitFileUrl $MaintTrimRc $SearchButton 
-  $EditNameLink $UseMetaWiki @ImageSites $BracketImg );
+  $EditNameLink $UseMetaWiki @ImageSites $BracketImg $BodyOnly );
 # Note: $NotifyDefault is kept because it was a config variable in 0.90
 # Other global variables:
 use vars qw(%Page %Section %Text %InterSite %SaveUrl %SaveNumUrl
@@ -175,6 +176,7 @@ $SearchButton = 0;      # 1 = search but
 $EditNameLink = 0;      # 1 = edit links use name (CSS), 0 = '?' links
 $UseMetaWiki  = 0;      # 1 = add MetaWiki search links, 0 = no MW links
 $BracketImg   = 1;      # 1 = [url url.gif] becomes image link, 0 = no img
+$BodyOnly     = 0;      # 1 = output body for template 0 = full HTML output
 
 # Names of sites.  (The first entry is used for the number link.)
 @IsbnNames = ('bn.com', 'amazon.com', 'search');
@@ -1338,6 +1340,8 @@ sub GetHttpHeader {
   my ($type) = @_;
   my $cookie;
 
+  return "" if $BodyOnly;
+
   $type = 'text/html'  if ($type eq '');
   if (defined($SetCookie{'id'})) {
     $cookie = $q->cookie(
@@ -1362,6 +1366,8 @@ sub GetHtmlHeader {
   my ($title, $id) = @_;
   my ($dtd, $html, $bodyExtra, $stylesheet);
 
+  return "" if $BodyOnly; # omit header
+
   $html = '';
   $dtd = '-//IETF//DTD HTML//EN';
   $html = qq(<!DOCTYPE HTML PUBLIC "$dtd">\n);
@@ -1484,11 +1490,13 @@ sub GetCommonFooter {
   if ($FooterNote ne '') {
     $html .= T($FooterNote);
   }
-  $html .= '</div>' . $q->end_html;
+  $html .= '</div>';
+  $html .= $q->end_html unless $BodyOnly;
   return $html;
 }
 
 sub GetMinimumFooter {
+  return "" if $BodyOnly;
   return $q->end_html;
 }
 
--- a/config
+++ b/config
@@ -63,6 +63,7 @@ $ReplaceFile = 'ReplaceFile';   # 0 = di
 $TableSyntax = 1;           # 1 = wiki syntax tables, 0 = no table syntax
 $NewFS       = 0;           # 1 = new multibyte $FS,  0 = old $FS
 $UseUpload   = 0;           # 1 = allow uploads,      0 = no uploads
+$BodyOnly    = 0;           # 1 = output body for template 0 = full HTML output
 
 # Minor options:
 $LogoLeft     = 0;      # 1 = logo on left,       0 = logo on right
