Problems with Line Breaks in <pre> paragraphs
Problems with Line Breaks in <pre> paragraphs
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
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
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
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:
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:
Code: Select all
br {
margin: 10px;
}Thanks for responding so quickly. I'm pulling my hair out here.judebert wrote:Couldn't you use <blockquote> or <code> instead of <pre>? Just saying.
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?
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/> 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 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.The <BR> not showing up in IE, I'm a little more confused about. I'd try adding this to my CSS:Code: Select all
br { margin: 10px; }
Cheers,
Doug
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Problems with Line Breaks in <pre> paragraphs
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.
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
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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Problems with Line Breaks in <pre> paragraphs
Garvin, Thanks for the detailed and prompt reply.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.![]()
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?
Yes, that's correct.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?
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.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...
Thanks again for your help.
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Problems with Line Breaks in <pre> paragraphs
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.

Best regards,
Garvin
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.
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.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.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
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.
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
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?
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?
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Hmmm. I don't think SQL has a search-and-replace command. Then again, Google shows:
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.
And of course you'll want to know what table to do the replacement in; I'll check that out soon.UPDATE yourtable
SET emailcolumn
= REPLACE(emailcolumn,'asd.k12.ak.us','asdk12.org')
WHERE emailcolumn like '%asd.k12.ak.us%'
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.
Cool - cheers!judebert wrote:
I'm actually making a bit of head-way ... I think
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Okay, so if Google is any good, you should be able to do this:
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.
Code: Select all
UPDATE serendipity_entries SET body = REPLACE(body, "pre>", "code>");
UPDATE serendipity_entries SET extended = REPLACE(extended, "pre>", "code>");
Round and round in circles
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
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
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Re: Problems with Line Breaks in <pre> paragraphs
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?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...
--
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
Doug Burns - Oracle DBA
dougburns@yahoo.com
http://oracledoug.com
http://oracledoug.com/serendipity
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
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
ChiaJesus: Hm, where do you copy code from and to? What does your resulting entry look like, give us an URL.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/