Maintaining Linebreaks in News Items

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Maintaining Linebreaks in News Items

Postby Gansos » Sun Sep 04, 2005 8:52 pm

I have an issue that is not completely unique, but my take on it is. Also, I have been unable to find a workable solution on these boards.

I'm using Coranto to manage "static" pages. The content generated by Coranto is built into different files for different pages in the site. I use PHP to include those files into the website's static pages. In other words, the static pages are just wrappers for Coranto's content.

My problem is that within a news post (that will eventually be the content of a page), I often have html code with meaningful linebreaks. However, Coranto either strips all linebreaks from a post, or replaces all linebreaks with <br> tags.

What I really need it to do is just leave the linebreaks intact so that the organizational structure of the html is not lost on submission. Obviously, such a simple solution would not work, as linebreaks mess up newsdat.txt.

Is there a way to do some kind of liinebreak translation, so that in the database, linebreaks are some kind of innocuous pattern("//n/" for example), but when news is built or edited, the linebreaks are translated back so that the original content appears correctly?

The motivation for such a solution is best illustrated with an example: I have a <ul> list of 100 items, with each item in an <li> tag. Each <li> is on its own line, and some <li>'s have other <ul>'s nested in them for sub-lists. When the line breaks are removed, all the nesting and spacing is lost, so it is almost impossible to figure out the structure of the list when editing it.

I would write an addon myself that did this linebreak translation, but I'm not familiar enough with the core to know where such an operation would hook in.

Any help would be much appreciated.
Gansos
 
Posts: 62
Joined: Thu Jan 11, 2007 8:33 pm

Postby SomeGuyNamedJim » Sun Sep 04, 2005 9:30 pm

I think there was an addon called NoBR a while back that fixed the problem.
SomeGuyNamedJim
 
Posts: 73
Joined: Thu Jan 20, 2005 3:12 am

Postby SrNupsen » Sun Sep 04, 2005 9:31 pm

My best bet would be the Search and replace addon by Parahead. Correct me if I'm wrong, but I think it would work like this (using your //n/ example):

- Make sure "Convert newlines to <BR>" is turned OFF for that news field
- Wherever you want a linebreak in your news, you just put //n/
- When news are built, any //n/ will be replaced with <br> (or <br />, or whatever you choose). This is done on the fly when building.
- If you modify a news item, you'll still see the //n/ on the modify news screen.

It also has other nifty features.

SrNupsen
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Gansos » Sun Sep 04, 2005 10:01 pm

Thanks for the reply. That is somewhat helpful, but it doesn't solve the problem completely.

When I use the term linebreak, I don't mean an html <br> tag. I mean a metacharacter "\n" break.

What I want to do is keep the whitespace intact when I submit a news item. Coranto leaves spaces, but strips return characters (\n, \r.).

Your suggestion makes sense for the purpose of inserting <br>'s in the final code, but does not solve the problem of keeping whitespace intact.

A search and replace scheme might work, but only if it intercepted the news before the breaks were stripped. That way, it could replace all \n or \r characters with //n/ when writing the news to the database, and reverse the process when pulling news out of the database. Maybe search and replace can be modified to do this?
Gansos
 
Posts: 62
Joined: Thu Jan 11, 2007 8:33 pm

Postby SrNupsen » Sun Sep 04, 2005 11:24 pm

Ops, this is over my head I'm afraid. Hopefully somebody more l33t can help you out! :wink:

10 PRINT "SrNupsen"
20 END
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby bozoka45 » Mon Sep 05, 2005 7:20 am

Enable \n escaping, and then use the addon Prisoner's Dilema. I think we're on the same page, not sure though.
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans

Postby Parahead » Mon Sep 05, 2005 8:01 am

Set the convert newlines option to yes, and define an entry in the S&R addon to replace <br> tags to \n in the output:
Convert "<br( \/)?>" to "\n" and set the "Allow Metacharacters?" checkbox to checked and it should do what you want, that is convert both <br> and <br /> tags to newlines.

Normally when the "Convert Newlines?" option is set to Yes it is hard to know if it was a newline or a real <br> tag you entered in the textarea. I don't know if that is a problem for you to convert both to newlines in the output or if you want to keep manually entered <br> tags unchanged in the output? If so, you can of course tweek the above a little to only convert <br /> *or* <br> and use the other when you post a newsitem to maintain it unchanged in the output.

Made any sense?
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Gansos » Mon Sep 05, 2005 12:30 pm

OK. I'll play around with that. Preliminary testing is looking positive.

Thanks for the help!
Gansos
 
Posts: 62
Joined: Thu Jan 11, 2007 8:33 pm


Return to Customization

Who is online

Users browsing this forum: No registered users and 1 guest

cron