1st some background: We run an online news magazine where the news is reported by the People.
So people can load the articles from their PC, Laptops, any device with a Web connection.
This means our reporters have all different size Web browsers & Screens.
Also they can add fotos to the articles which fotos are floated using CSS.
The problem that we are trying to address is how to get the same consistent line wrapping, keeping in mind that we parse the article to hyperlink any included URLs. An example would best describe the problem we are having, please look here:
as you can see the lines are not wrapping the same for the 1st few paragraphs and thus causing awkward display of the text. Well this awkward gap in the lines consists through out our article pages but is worse regarding lines that are next to CSS floating images.
Do you have suggestion as to what we can do to cause the lines to wrap nicely. No matter where our reporters clicked on the Enter key to cause a new line since again we have no control over the reporter since they are the public at large.
Your data is nasty. Clean it up.
Your post likely includes some weird characters, probably a new-line symbol everynow and then. This is what is causing all the line-breaks.
You should be able to fix this by copy-pasting into a plain-text editor like notepad, and then copy/pasting back into your file and re-saving over itself. In the long-run though, you need to make sure your data is clean.'
EDIT: Okay, re-read your post. If your reporters are doing this, I would make sure they are composing their articles in a plain-text environment where they can't accidentally introduce odd symbols/line-breaks. Maybe they are going from Microsoft Word to Wordpress? I am not sure exactly how they may be accidentally introducing the broken characters.
Yes, thats the thing. We have no real control over what the People (aka Reporters) use to compose their articles.
As this SitePoint has not control over what people use to compose their Questions & Answers.
So just as this SitePoint still displays the Text nicely. My question is is there a way, a Php code, that will force
the Text to display nicely, evenly, no matter what Text Editor they used to compose their articles and then
pasted that into the RealNewsPost.com page from where they submit their Articles.
That is the Question?
FYI: from what I hear most People (reporters) just type their articles right into the TEXTAREA form field
of the article submit page.
Thats a good question. There is the method htmlentities() which returns a non-html containing version of a string. That may remove those '<br>' tags.
Use a responsive theme from WordPress, problem solved
If you are using Wordpress, there is a "paste from Word" feature in the editor that you can use to clean up any
hidden formatting from Word documents. It's in the middle of the second row of icons. Would that help?
We are not using WordPress.
This site is entirely built inhouse with Php, MySQL, etc.
keywordsear.ch , just wanted to let you know that I tried your suggestion of
and it does not work at all, which you can see here:
You have to identify "real" line breaks and remove all other line breaks to let user's browsers do the proper line breaking. That's a tough job indeed. It might require you to identify the sender's software. How is the data uploaded? If by file upload you know the file's extension/application which is a good start.
The data is uploaded via a Web browser form, just as it is here in SitePoint.
So the People just type in their articles in a Web browser form, that is into <textarea> field and submit it like that.
Well if you want just the text, strip_tags the text.
If you're wanting to turn BR's into Newlines, str_replace multiple BR's into one, and then str_replace the single BR's into \
's. (or \r\
's, if you're feeling fancy)
need to force the text into a given word wrapping? wordwrap().
PS: Your original example looks fine to me.
Perhaps adding editor functionality to the textarea that they are typing their article in will help - for example http://www.tinymce.com/
That will allow them to use formatting buttons to define how their article is supposed to be formatted and will hopefully discourage them from entering their own improper formatting.
TinyMCE also has a plugin that provides a paste option that will strip out all the junk when pasting from Word.
Can you post/send/upload the original "blurb" that you would like inserting and I will endeavour to use format the "blurb" correctly.
First attempt: http://www.johns-jokes.com/downloads/sp-b/realnewspost/
FYI: The original example I gave you looks fine because we manually corrected the Text of that article.
But of course that is not a viable option for us to manually correct all submitted articles.
Now as to the 1st part of your answer, I played with that idea but results were worse.
This topic is now closed. New replies are no longer allowed.