HTML in post adding extra < br/> tag?

Started by JTVaughn, September 17, 2015, 09:49:51 AM

Previous topic - Next topic

JTVaughn

I asked in the feed poster mod thread, but I think this issue is down to SMF itself rather than the mod, so was hoping one of you code experts may know.

The feed poster grabs an RSS post and posts it on your forum, in HTML tags if selected. However, there's a formatting issue. The posts have all got double line spacing. So instead of


Line 1

Line 2

Line 3


It gets turned into


Line 1


Line 2


Line 3


This is because extra <br> tags are added between closing and opening <p> tags, like this:

</p><br /><p>

So the RSS post you're grabbing has content in <p> tags like normal, but when brought into SMF there's an extra <br /> added in between each paragraph. So one paragraph tag closes, SMF chucks in a <br />, then the next paragraph begins. But <p> already spaces it out, so the <br /> isn't required.

Does anyone know what's causing this? I've looked through all the mod's php files and can't see anything that controls formatting. I thought I found something in subs-editor that might be doing it, but changing that didn't work. This is in the latest SMF version. I am very much a novice so any simple advice would be appreciated.  ;)

margarett

I'm not sure where the problem comes from, really.

I don't know why is it adding the <p>. If isn't necessary. If you look at the page source for your post (or mine) you see that there is no <p> in it, the line breaks are just <br />'s
If you write content inside HTML tags, <p> isn't added also.

But after a quick look at the MOD's code I also don't see where it might happen. For now we should wait for vbgamer45's reply ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

JTVaughn

Quote from: margarett on September 17, 2015, 11:42:11 AM
I'm not sure where the problem comes from, really.

I don't know why is it adding the <p>. If isn't necessary. If you look at the page source for your post (or mine) you see that there is no <p> in it, the line breaks are just <br />'s
If you write content inside HTML tags, <p> isn't added also.

But after a quick look at the MOD's code I also don't see where it might happen. For now we should wait for vbgamer45's reply ;)

The <p> tags are coming from the RSS feed, aren't they?

For instance, the source of this http://feeds.feedburner.com/ThewrapTheWalkingDead

<p>The kickoff for the prequel to &#8220;The Walking Dead&#8221; drew 10.1 million total viewers. The premiere also drew 6.3 million adults 18-49, according to Nielsen.</p>
<p>The 9 p.m. premiere drew a 4.9 Nielsen rating among adults 18-49 and a 5.3 rating among adults 25-54.</p>


But when brought into SMF by the feed poster mod, it changes to

<p>The kickoff for the prequel to &#8220;The Walking Dead&#8221; drew 10.1 million total viewers. The premiere also drew 6.3 million adults 18-49, according to Nielsen.</p><br /><p>The 9 p.m. premiere drew a 4.9 Nielsen rating among adults 18-49 and a 5.3 rating among adults 25-54.</p>

With the <br /> in the middle. Trying to figure out where that <br /> comes from is a bit of a headache :D

vbgamer45

It looks like the \n  the new line character is changed to <br />
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

JTVaughn


vbgamer45

Probably best in subs-rss feed post remove \n but that won't work for everyone and might mess up some other feeds.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

JTVaughn

Where is this \n located that controls it?

If anyone else has any ideas, feel free to chip in -_-

vbgamer45

\n is a new line in the feed anytime goes down to new line that uses a \n
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

JTVaughn

Looks to be quite complex, and impossible, judging by the discussions in

http://www.simplemachines.org/community/index.php?topic=346797.0
and
http://www.simplemachines.org/community/index.php?topic=344103.0

:(

I don't like the extra line breaks it causes, but there seems to be no solution at all

JTVaughn

If the \n / <br /> thing cannot be changed, is there anything that can be done about the <p> tags? Can they be stripped out of the post somehow? Or can the behaviour of the <p> be altered?

Illori

what about the <p> tags do you want changed?

JTVaughn

No line break, like if it were a simple <b> tag or an <i> tag. I don't really know at what point this styling is done. Is it defined by the browser itself, so tag behaviour can't be changed?

Illori

can you provide a link to one of these topics so we can take a look at it? otherwise we may not be able to answer that.

JTVaughn

It's being tested in a private admin area, but I can show you

Output:


The HTML code generated by the feed poster to display this:

[html]<p>ABC&#8217;s &#8220;Scandal&#8221; and AMC&#8217;s &#8220;The Walking Dead&#8221; have the most loyal Twitter followings, according to a study released by Nielsen on Monday.</p><br /><p>The researchers&nbsp;looked at Twitter users who tweeted about a show during three or more episodes over the course of a season, looking at all television shows on the air between September 2014 and May 2015.</p><br /><p>&#8220;Scandal&#8221; topped the list with 24 percent of those tweeting about the hit Shondaland show during at least three episodes throughout&nbsp;the season. But the &#8220;The Walking Dead&#8221; was nipping at Olivia Pope&#8217;s heels with 23 percent. Fox&#8217;s new smash hit &#8220;Empire&#8221; also came in near the top with 22 percent.</p><br /><p><br /><notag><p class="ctx-link"><strong>Also Read:</strong> <a class="also-read-counter" href="http://www.thewrap.com/snapchats-leaked-financials-show-social-media-company-is-hemorrhaging-money/" target="_blank">Snapchat&#039;s Leaked Financials Show Social Media Company Is Hemorrhaging Money</a></p></notag><br /></p><br /><p>See the full breakdown of most loyal Twitter followers by show below.</p><br /><p><br /><notag><div id="attachment_535265" style="width: 610px" class="wp-caption alignnone"><a href="http://p1cdn05.thewrap.com/images/2015/08/nielsen-social-loyalty-2.jpg"></a><p class="wp-caption-text">Nielsen</p></div></notag><br /></p><br /><p>The study also determined that more loyal Twitter users exhibited different behaviors from other users of the social media site. They send an average of three times more tweets per episode of a show, have 50 percent more followers and are 70 percent&nbsp;more likely to tweet about brands, making them incredibly valuable targets for&nbsp;advertisers.</p><br />

Which comes from this feed http://feeds.feedburner.com/ThewrapTheWalkingDead

Kindred

well, either the original feed has it.... or the RSS parser/importer adds it...  it's not something that SMF does, AFAIK.

Why are you putting those into HTML tags anyway?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

JTVaughn

Quote from: Kindred on September 17, 2015, 04:16:09 PM
well, either the original feed has it.... or the RSS parser/importer adds it...  it's not something that SMF does, AFAIK.

Why are you putting those into HTML tags anyway?

I'm not putting them in the tags, it's done by the feed poster. You can select to use HTML or not. If you choose to not, you lose all of the formatting of the post, such as embedded links and alignment. Everything loads perfectly with the HTML on, except for the <p> and <br> issue. Either way I'd have to edit every post the feed grabs myself to get the formatting correct, which sort of defeats the purpose of an automated system.

margarett

Without major investigations, I'd suggest a string replace before the post gets submitted to the database, replacing <br /></p> with just </p>
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

JTVaughn


margarett

#18
I'm not at the computer now but str_ireplace before the call to createPost in the Subs-something :P file should do it
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kindred

except, what I am suggesting is that it is something in the RSS mod when the feed is imported that is adding the extra p and br code...

so, instead of a replace for messy code, why not fund the section of the mod code that is adding extraneous code and fix that? :)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: