Opened 18 years ago
Last modified 14 years ago
#110 new enhancement
Genshi doesn't add newline char after "</html>"
Reported by: | yaohua2000@… | Owned by: | cmlenz |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Template processing | Version: | 0.3.6 |
Keywords: | Cc: |
Description
My template ends with "</html>" and a newline char, but after "genshied", it removed my newline char at the end of file. A text file should be ended with a newline char. Please add it back.
Attachments (1)
Change History (8)
comment:1 Changed 18 years ago by anonymous
comment:2 Changed 18 years ago by cmlenz
- Milestone changed from 0.4 to 0.4.1
I agree that Genshi shouldn't be stripping whitespace after the last close tag. Will look into this for 0.4.1.
comment:3 Changed 18 years ago by anonymous
Well, generally spoken, whitespace after close tags *is* important to create far more readable output. So I agree in that Genshi shouldn't strip it.
comment:4 Changed 18 years ago by cmlenz
Okay, the problem is that whitespace after the document element is “ignorable whitespace”, and thus not passed to Genshi as normal character data. The only way to learn about such whitespace is using the DefaultHandler (implemented by XMLParser._handle_other in Genshi), but then we also get a whole lot of other ignorable whitespace, which, well, ought to be ignored.
So right now I'm not sure what the right solution would be.
comment:5 Changed 18 years ago by cmlenz
- Milestone changed from 0.4.1 to 0.5
- Priority changed from major to minor
For the reasons explained in my previous comment, I consider fixing this issue to high risk for the maintenance branch. I'll look into a proper solution for 0.5.
comment:6 follow-up: ↓ 7 Changed 17 years ago by cmlenz
- Milestone 0.5 deleted
- Type changed from defect to enhancement
Postponing again, sorry. If anyone can come up with a patch for this, I'd be grateful.
comment:7 in reply to: ↑ 6 Changed 14 years ago by Carsten Klein <carsten.klein@…>
Replying to cmlenz:
Postponing again, sorry. If anyone can come up with a patch for this, I'd be grateful.
Why not make this a feature of the serializers found in the output module?
However, it should be made configurable whether the serializer should add a new line character at the end of the output.
See the attached propopsal for an untested patch.
While your template file might be a text file, (X)HTML output is not. And in XML, there is nothing outside the root element, so having no newline makes sense to me.