worldnews — 2013-04-28T18:01:45-04:00 — #1
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.
keywordsear_ch — 2013-04-28T18:04:07-04:00 — #2
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.
worldnews — 2013-04-28T20:46:58-04:00 — #3
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.
keywordsear_ch — 2013-04-28T21:03:15-04:00 — #4
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.
mazz — 2013-04-28T22:20:23-04:00 — #5
Use a responsive theme from WordPress, problem solved
webmachine — 2013-04-28T22:28:53-04:00 — #6
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?
worldnews — 2013-04-29T00:28:13-04:00 — #7
We are not using WordPress.
This site is entirely built inhouse with Php, MySQL, etc.
worldnews — 2013-04-29T11:59:19-04:00 — #8
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:
captainccs — 2013-04-29T15:54:29-04:00 — #9
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.
worldnews — 2013-04-30T12:52:15-04:00 — #10
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.
captainccs — 2013-04-30T13:12:45-04:00 — #11
starlion — 2013-04-30T15:27:05-04:00 — #12
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.
felgall — 2013-04-30T17:39:34-04:00 — #13
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.
john_betong — 2013-05-03T01:28:52-04:00 — #14
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/
worldnews — 2013-05-05T15:17:41-04:00 — #15
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.