Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: [micro-mini-MOD] </p> validation on [break] short text  (Read 2749 times)

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[micro-mini-MOD] </p> validation on [break] short text
« on: May 09, 2007, 12:10:37 PM »

When people plonk a [break] part way through a paragraph (because that is all they want as a leader to the article), the page then fails to validate.

This mod will rectify this problem.

locate file_include() function in snews.php.
grey = original file_include() code.
blue = is what you need to add.
brown = a comment that you can leave in, or remove.
Quote
function file_include($text, $shorten) {
   $fulltext = substr($text, 0, $shorten);

if ($shorten < 9999000 && preg_match('<p>',$fulltext)){
// count all start and end tags, provided count of <p> is more, add </p>
   if(substr_count ($fulltext, '<p>') > substr_count ($fulltext, '</p>')){
   $fulltext .='</p>';}}

   $inc = strpos($fulltext, '[/include]');
   if ($inc > 0) {
      $text = str_replace('[include]', '|&|', $fulltext);
note, if the [break] is place inside any other paired elements(<span></span>,<em></em>, etc), it will not fix them up for you.
« Last Edit: November 11, 2008, 04:47:21 PM by Joost »
Logged
Of all the things I have lost, it is my mind that I miss the most.

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [micro-mini-MOD] </p> validation on [break] short text
« Reply #1 on: November 11, 2008, 10:45:20 PM »

(because that is all they want as a leader to the article)

;D ;D ;D

Edit:
-----------------------------
On Blogger.com, Google are using another method for articles.
Everything you write is included inside of only one pair <p></p>
And is working as your mod for article editor.
And formatting is made with <style> .

Not a method for us but in theory, is "bullet proof" for non tech clients ...  because in practice, I saw few Wordpress.com blogs with broken style because of bad html code... 
I think we need a "sNews variant" like this for blogging amateurs...
« Last Edit: November 11, 2008, 10:58:50 PM by funlw65 »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [micro-mini-MOD] </p> validation on [break] short text
« Reply #2 on: November 12, 2008, 02:49:35 AM »

I forgot to note it earlier... but I added Phimoz's patch (above) to the Official 1.6 Download today as well... and posted a Patch notice on the 1.6 Patches and Fixes Board.  ;)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU