%# BEGIN LICENSE BLOCK
%# 
%#  Copyright (c) 2002-2003 Jesse Vincent <jesse@bestpractical.com>
%#  
%#  This program is free software; you can redistribute it and/or modify
%#  it under the terms of version 2 of the GNU General Public License 
%#  as published by the Free Software Foundation.
%# 
%#  A copy of that license should have arrived with this
%#  software, but in any event can be snarfed from www.gnu.org.
%# 
%#  This program is distributed in the hope that it will be useful,
%#  but WITHOUT ANY WARRANTY; without even the implied warranty of
%#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%#  GNU General Public License for more details.
%# 
%# END LICENSE BLOCK

#<%$Article->Id%>: <%$Article->Name%>
<%'-' x length("#".$Article->Id.": ".$Article->Name) %>

<% $Article->Summary%> 

%my $cfs = $Article->ClassObj->CustomFields;  
% while (my $cf = $cfs->Next) {

% my $values = $Article->CustomFieldValues($cf->Id);
% if ($cf->Type eq 'TextSingle') {
% my $value = $values->First; 
% my $content = $value->Content;
% if ($content =~ /<(.{1,5})>/) {
%    $content = de_htmlify($content);
% }
<%$cf->Name%>:
<%'-' x length($cf->Name) %>
<%$content%>
% } else {
% my $val = $values->Next;
% my $content = $val->Content;
% if ($content =~ /<(.{1,5})>/) {
%    $content = de_htmlify($content);
% }
<%$cf->Name%>: <%$val && $content%>
% while ($val = $values->Next) { 
% my $content = $val->Content;
% if ($content =~ /<(.{1,5})>/) {
%    $content = de_htmlify($content);
% }
<%' ' x length($cf->Name)%>  <%$content%>
% } 
% }
% }

<%init>
sub de_htmlify {
    my $content = shift;
    require HTML::TreeBuilder;
    my $tree = HTML::TreeBuilder->new;
    $tree->parse($content);
    $tree->eof();

    require HTML::FormatText;
    my $formatter = HTML::FormatText->new(leftmargin => 0, rightmargin => 50);
    $content = $formatter->format($tree);
    return $content;
}
</%init>

<%args>
$Article
</%args>
