Page 1 of 2
Problems with Line Breaks in <pre> paragraphs
Posted: Wed Jul 12, 2006 9:10 pm
by dougburns
I use code examples a lot and have redefined the <pre> tag in my template. However, although <br> tags can be inserted, these show correctly in Firefox but disappear in IE5. Here is the site
http://oracledoug.com/serendipity. Is there a better way to approach this? What am I doing wrong?
I'm also having problems with <br> tags in comments imported from another blogging tool at Tripod. The comments on recent posts are fine, but this one , for example shows <BR> as text instead of inserting a line break.
http://oracledoug.com/serendipity/index ... l#comments
Any help with these problems would be *much* appreciated.
Cheers,
Doug
Posted: Wed Jul 12, 2006 10:05 pm
by judebert
Couldn't you use <blockquote> or <code> instead of <pre>? Just saying.
The <BR/> in comments is probably because Serendipity doesn't allow HTML in comments. You could install the
serendipity_event_unstrip_tags "Transforms HTML for Comments" plugin to take care of that.
The <BR> not showing up in IE, I'm a little more confused about. I'd try adding this to my CSS:
Posted: Wed Jul 12, 2006 10:15 pm
by dougburns
judebert wrote:Couldn't you use <blockquote> or <code> instead of <pre>? Just saying.
Thanks for responding so quickly. I'm pulling my hair out here.
I'm happy to use either, but it's going to be a pretty big tag replacement! Is this something that's pretty easy to do at the back-end?
The <BR/> in comments is probably because Serendipity doesn't allow HTML in comments. You could install the
serendipity_event_unstrip_tags "Transforms HTML for Comments" plugin to take care of that.
I have that installed as the first event plug-in. I assumed that was why the breaks work okay in newly-posted comments.
The <BR> not showing up in IE, I'm a little more confused about. I'd try adding this to my CSS:
I gave that a try and it made Firefox double-space the code examples and IE *still* doesn't show any white-space for the breaks.
Cheers,
Doug
Re: Problems with Line Breaks in <pre> paragraphs
Posted: Thu Jul 13, 2006 1:00 pm
by garvinhicking
Hi!
Thie IE-double BR problem sure looks weird. Maybe it is because your stylesheet CSS file contains this:
Code: Select all
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=582575;
var sc_invisible=0;
var sc_partition=4;
var sc_security="a26f5081";
</script>
<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img src="http://c5.statcounter.com/counter.php?sc_project=582575&java=0&security=a26f5081&invisible=0" alt="counter easy hit" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
Where did you enter this code? It shouldn't actually be there.
Your second problem about the comment breaks - did I understand correctly that new comments properly work when people enter <br> but not for your imported comments?
Could you check the serendipity_comments table and see what code exactly is contained in the cells where "<BR />" happens, and compare that to how the code looks in new comments? You might need to do some search+replace for your old comments then...
Best regards,
Garvin
Re: Problems with Line Breaks in <pre> paragraphs
Posted: Thu Jul 13, 2006 1:26 pm
by dougburns
garvinhicking wrote:Hi!
Thie IE-double BR problem sure looks weird. Maybe it is because your stylesheet CSS file contains this:
Where did you enter this code? It shouldn't actually be there.
Garvin, Thanks for the detailed and prompt reply.
I suspect a little knowledge is a dangerous thing in my case. I wanted to include the Statcounter code but wasn't entirely sure I'd picked the right place. Where should I be putting it?
Your second problem about the comment breaks - did I understand correctly that new comments properly work when people enter <br> but not for your imported comments?
Yes, that's correct.
Could you check the serendipity_comments table and see what code exactly is contained in the cells where "<BR />" happens, and compare that to how the code looks in new comments? You might need to do some search+replace for your old comments then...
Cool, I'll give that a try. I don't have access until later tonight and I'll need to work out MySQL (which seems funny, as an Oracle DBA!) but I'll see how I get on.
Thanks again for your help.
Re: Problems with Line Breaks in <pre> paragraphs
Posted: Thu Jul 13, 2006 1:47 pm
by garvinhicking
Hi Doug!
The best place to put the statcounter is within the "index.tpl" file of your template. You should always avoid editing core serendipity files - in serendipity, there should never be the need to edit any of our .php files, since we keep everything separated in nice, little, shiny template markup.
I suppose you put it into your index.php? Let's see if removing it there will help in the IE problem.
Cool, I'll give that a try. I don't have access until later tonight and I'll need to work out MySQL (which seems funny, as an Oracle DBA!) but I'll see how I get on.
Sure, okay - no problem. If you face problems, let me know. Using tools like phpMyAdmin or the MySQL GUI should help you instantly, I suppose.
Best regards,
Garvin
Posted: Thu Jul 13, 2006 4:30 pm
by judebert
Well, now you've got me about to tear out my hair, too. Of course, I've got lots, so no great loss.
I can't Google any IE5 <br> problems. And it's working fine from my work box, IE6/XPSP2.
Let's hope removing the invalid CSS fixes the problem. When you put it in there, remember that Smarty parses the index.tpl file, and it uses {} as delimiters. You'll either need to substitute {ldelim} and {rdelim} (which Smarty turns into { and }, respectively) or put the whole thing between {literal} tags.
The latest status
Posted: Fri Jul 14, 2006 8:27 pm
by dougburns
Well, it would appear that using <pre> tags is the problem here.
I moved the statcounter code to index.tpl. It didn't fix the line spacing problem, but I'm glad understand where to put it anyway ;-
If I switch to <code>, things look fine. In retrospect, I should have used code tags from the start, but I was importing a ton of blogs from elsewhere that already used the <pre> tags.
In a way it kind of makes sense - if the text is preformatted, <br> tags make less sense but it's a pretty big difference between the browsers!
What I could really use now is the procedure to replace all of the <pre> tags in all of my blogs with <code> tags. Unfortunately I know nothing about mysql, but I'll see if can find something in the forums. Unless it's something that's quite straightforward?
Posted: Fri Jul 14, 2006 8:56 pm
by judebert
Hmmm. I don't think SQL has a search-and-replace command. Then again, Google shows:
UPDATE yourtable
SET emailcolumn
= REPLACE(emailcolumn,'asd.k12.ak.us','asdk12.org')
WHERE emailcolumn like '%asd.k12.ak.us%'
And of course you'll want to know what table to do the replacement in; I'll check that out soon.
Of course, you should back up your database first. If you use a database dump to do it, you could just use a text-editor on a copy of that. Any search-and-replace function would do.
And, of course, you could wind up replacing valid <pre> tags, so you might want to examine the results to make sure everything is as you want it.
Posted: Fri Jul 14, 2006 8:58 pm
by dougburns
judebert wrote:
Cool - cheers!
I'm actually making a bit of head-way ... I think

Posted: Fri Jul 14, 2006 8:59 pm
by judebert
Okay, so if Google is any good, you should be able to do this:
Code: Select all
UPDATE serendipity_entries SET body = REPLACE(body, "pre>", "code>");
UPDATE serendipity_entries SET extended = REPLACE(extended, "pre>", "code>");
That should handle both <pre> and </pre>. Assuming you don't do anything like <pre class="myclass"> or something. If so, you'll have to add a few lines, although I think they're simple enough for you to figure out.
Round and round in circles
Posted: Sat Jul 15, 2006 3:58 pm
by dougburns
Wow, I'm spending a lot of time on this, but I'm learning things along the way, particularly about mysql, which is nice and easy if you've used another DBMS.
I updated all of the <pre> tags to <code> tags and it cured the line spacing problem but then text doesn't align as it should when outputting the results of queries in Oracle. I also struggled to get the shaded boxes I'm looking for which are straightforward when using <pre> tags.
So I switched back to <pre> and everything looks lovely apart from the damn line breaks. It did occur to me, though, that IE *is* handling line breaks if there's a single <br> but is collapsing two <br> tags into one.
I don't suppose there's much more anyone can do to help me but all of the help so far is much appreciated.
Cheers
Re: Problems with Line Breaks in <pre> paragraphs
Posted: Sat Jul 15, 2006 4:00 pm
by dougburns
garvinhicking wrote:Hi!
Could you check the serendipity_comments table and see what code exactly is contained in the cells where "<BR />" happens, and compare that to how the code looks in new comments? You might need to do some search+replace for your old comments then...
As for this problem, the <BR /> tags are in the database. If I want to replace them with new lines, what character should I be replacing them with?
Posted: Sun Jul 16, 2006 6:43 pm
by ChiaJesus
I'm having a simular problem.
Copy and pasting from a web page to a new entry strips the line spacing (blank lines between paragraphs)...
Is there a solution to this?
Posted: Mon Jul 17, 2006 11:42 am
by garvinhicking
Dougburns: You should replace it with "\n", that is a simple newline character in mysql.
ChiaJesus: Hm, where do you copy code from and to? What does your resulting entry look like, give us an URL.
Best regards,
Garvin