Skip Menu |

This queue is for tickets about the XML-Writer CPAN distribution.

Report information
The Basics
Id: 12777
Status: resolved
Priority: 0/
Queue: XML-Writer

People
Owner: Nobody in particular
Requestors: heikki [...] ebi.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.531
Fixed in: (no value)



Subject: better visibility to comments in data mode
In data mode, XML::Writer adds comments to the end of the previous line. My expected behaviour was that comments are indented like the line it precedes. The patch fixes that. In addition, I wanted to be able to add an extra new line before a comment for better readability. The patch does that by adding an optional second argument to comment(). If it evaluates to true, a line is added. The POD is amended accordingly.
*** /usr/lib/perl5/vendor_perl/5.8.6/XML/Writer.pm 2005-05-12 17:00:02.000000000 +0100 --- Writer.pm 2005-05-12 16:42:00.000000000 +0100 *************** *** 167,181 **** my $comment = sub { my $data = $_[0]; - my $space = $_[1]; - if ($dataMode && ($hasHeading || $elementLevel)) { - if ($space) { - $output->print("\n\n"); - } else { - $output->print("\n"); - } - $output->print(" " x ($elementLevel * $dataIndent)); - } $output->print("<!-- $data -->"); if ($elementLevel == 0) { $output->print("\n"); --- 167,172 ---- *************** *** 1273,1279 **** $writer->doctype("html"); ! =item comment($text [, $space_boolean]) Add a comment to an XML document. If the comment appears outside the document element (either before the first start tag or after the last --- 1264,1270 ---- $writer->doctype("html"); ! =item comment($text) Add a comment to an XML document. If the comment appears outside the document element (either before the first start tag or after the last *************** *** 1282,1290 **** $writer->comment("This is a comment"); - In data mode, when the optional second argument eveluates to true, - the module will an empty line before the comment. - =item pi($target [, $data]) Add a processing instruction to an XML document: --- 1273,1278 ----
Thanks; I've changed the comment formatting as suggested. I'm holding off on that extra parameter for now, because I want to avoid changing the interface wherever I can, but I'll keep it in mind.