[cgi-wiki-dev] Formatter::Pod and line endings
Tom Insam
cgi-wiki-dev@earth.li
Sun, 31 Oct 2004 19:35:32 +0000
--Apple-Mail-1-685048613
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
On Oct 31, 2004, at 14:35, Kake L Pugh wrote:
> On Fri 29 Oct 2004, Tom Insam <tinsam@fotango.com> wrote:
>> Rather than fix the formatter, I think it's probably better to ensure
>> that whatever formatter we use is always passed unix line endings.
>> This
>> patch (to CGI::Wiki) does this.
>
> I'd rather fix this in the formatter; can you send a patch for that,
> please?
Attached.
--Apple-Mail-1-685048613
Content-Transfer-Encoding: 7bit
Content-Type: application/text;
x-mac-type=54455854;
x-unix-mode=0664;
name="formatter.patch"
Content-Disposition: attachment;
filename=formatter.patch
diff -ur CGI-Wiki-Formatter-Pod-0.03/lib/CGI/Wiki/Formatter/Pod.pm CGI-Wiki-Formatter-Pod-dev/lib/CGI/Wiki/Formatter/Pod.pm
--- CGI-Wiki-Formatter-Pod-0.03/lib/CGI/Wiki/Formatter/Pod.pm Sun Oct 12 22:02:16 2003
+++ CGI-Wiki-Formatter-Pod-dev/lib/CGI/Wiki/Formatter/Pod.pm Sun Oct 31 19:32:30 2004
@@ -81,6 +81,10 @@
my $source = \$raw;
my $formatted;
my $dest = IO::Scalar->new( \$formatted );
+
+ # Ensure unix line endings
+ $dest =~ s/(\012|\015\012?)/\012/g;
+
my %options = ( link_map => $self->{_link_mapper} );
my $html = Pod::Tree::HTML->new( $source, $dest, %options );
$html->translate;
--Apple-Mail-1-685048613
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
But why? My preferred of the three patches is the 'fix before it goes
into the store' patch - I like the idea that you can trust what's in
the store to have this particular sort of line-ending. What happens
when some other formatter also makes this fairly reasonable assumption
about line-endings? The only flaw with it that I see is that we
probably _also_ need the line endings fixing patch for stuff coming out
of the store, to fix legacy data stores. But that's (a) transitional,
and (b) harmless.
tom
--Apple-Mail-1-685048613--