Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How comments are saved.
Maybe this has been addressed in RC3:
When comments are saved in Textpattern, it uses a subset of textile. One peculiarity I have found is that instead of using paragraphs to wrap a paragraph, the comments are saved with hard line breaks used to fake paragraphs. A couple questions: why is this done? Anybody know of a workaround to get Textile in comments to mark up the paragraphs properly? Does anybody know how I could go back through my old comments and reformat things so that <br />
are turned into <p> ... </p>
?
Basically, I’m trying to fix the way comments are displayed on my site, but the hard line breaks are making things difficult.
Offline
#2 2005-05-10 18:39:44
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How comments are saved.
Its because Textile is run in “lite” mode along with nl2br().
This is run when the comment is made, and so you’d have to go back and do this manually.
Why its done that way, its probably for security, as the way Textile is written, if you have the paragraphs, then you also allow images etc.
This can be manually fixed (hacked) in any version, somewhere around line 79 of comment.php is where it starts. You’d remove the nl2br function (make sure and remove the 2 parenthesis), and change the “1” to a “0”.
Offline
#3 2005-05-10 19:00:44
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: How comments are saved.
That still wouldn’t create the paragraph tags you’re looking for (unless you completely shut off lite mode, which I’m not sure how safe that is). Since it’s in lite mode, it’s not rendering any block elements (i.e. images/tables/paragraphs/etc). Check the function block()
in classTextile.php
. This code block around line 251 prevents block elements (which includes paragraphs) from being rendered.
I’ve also been bothered by this. I’m not sure of a way around it… perhaps there’s a way though. I’ll keep digging.
Offline
#4 2005-05-10 19:15:27
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: How comments are saved.
Actually, you’re right mary… it does work. I’m not sure what are the implications of performing normal textile mode on comments though.
Offline
#5 2005-05-10 19:39:52
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: How comments are saved.
So this change would allow the following to be inserted into comments by use of textile (images would not respect admin prefs):
<span style=“line-height:18px”>- paragraphs (all text wrapped by <p>
by default) <br>
- images <br>
- lists <br>
- tables <br>
- blockquotes <br>
- headers <br>
- footnotes<br>
Am i missing anything? I don’t think there’s anything potentially damaging there, mainly because all tags would be stripped out anyways; the most potential for damage is someone posting textile tables or headers that blow out your layout. It’d be nice if paragraphs were possible without having to open the gates.
Last edited by Andrew (2005-05-10 20:09:44)
Offline
#6 2005-05-10 20:12:31
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: How comments are saved.
Oh, btw… you’ll have to perform the same changes to lines 302-4 of comments.php in saveComments()
so that the textile changes carry over to the stored comment.
Offline
Re: How comments are saved.
Thanks. I don’t see the harm in blockquotes, lists, and paragraphs. I can see problems arising for letting users using tables (as things may render strange), and posting images (since they can be not safe for work, or your eyes for that matter). I’ll try modifying the source tonight and see how it goes.
Offline
#8 2005-05-10 21:32:54
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: How comments are saved.
I don’t ever create tables with textile anyways, so — since I sort of want this functionality too — I’ll likely just remove the tables bit from classTextile.php
altogether. Images are ok, and with CSS you can control overflow.
Offline
Re: How comments are saved.
Hey guys,
Sorry to bump an old topic, but I’ve got the problem, described by ramanan in the first post. I’m using TXP 4.0. I’d like to have each “paragraph” in a comment wrapped in P tags, not separated by a BR. Any ideas? Does the dirty hack Mary proposes work in 4.0?
Thanks!
Offline
#10 2005-08-29 07:49:24
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How comments are saved.
Boby, the hack will still work, the function has just been moved, that’s all. :) You’ll find it starting at line 1112 of txplib_misc.php.
Offline
Re: How comments are saved.
That worked! Thanks!
Now, is there any way to “process” all the comments in my database? I need to strip the BR tags from those and wrap the lines in Ps. Manually editing comments one by one won’t do…
Offline
Re: How comments are saved.
Yeah, a way to bulk process old comments would be quite handy. I imagine you might be able to do this sort of thing with some fancy regex operations perhaps? Has anyone thought about this more?
Offline