Gossamer Forum
Quote Reply
clean html
Is there a way to change the display of FormatText from this (in the source of the page)
1111
2222
3333
4444 to this
111 2222 3333 4444
I use this code to clean HTML code sub { my $content = $_[0]; $content =~ s/<.*?>//g; return $content; }
But in the source of the page the line are brake like in the example, there is no HTML code in the FormatText.
So is there a way that in the source of the page there will not the brake line?
Quote Reply
Re: [nir] clean html In reply to
Hi,

You wanna change it so instead of being returned in more than 1 line, it will just return it as a single line?

This should work:

Code:
$var =~ s/\n/ /sig;

..so will replace newlines with " " (so the words don't get scrunched up together)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] clean html In reply to
Thanks,
when I use this code { my $content = $_[0]; $content =~ s/<.*?>//g; return $content; } it clean the HTML.
when I use sub { my $content = $_[0]; $content =~ s/\n/ /sig; return $content; } it return the html as one line but with HTML code, how we can return the code without the HTML code in one line?
Quote Reply
Re: [nir] clean html In reply to
Hi,

I was refering to just "adding" that new line - not replacing it :)

This should work:

Code:
sub {
my $content = $_[0];
$content =~ s/<.*?>//g;
$content =~ s/\n/ /sig;
return $content;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] clean html In reply to
It return the code wit h line breakWhistle.
Quote Reply
Re: [nir] clean html In reply to
Can you post an example of the **HTML** (i.e when you "view source" on the page) ... so I can see it?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] clean html In reply to
No problem!!


<div class="yn-story-content">
<p>MOUNT MERAPI, Indonesia – Towering clouds of hot ash gushed from the mouth of Indonesia's deadly volcano Thursday, hours after its most explosive eruption in a deadly week sent screaming women and children fleeing mountainside villages and emergency shelters.</p>
<p>Scientists — shaking their heads as they watched the wide, fast sweeps of a needle on a seismograph — worried that the worst might be yet to come.</p>
<p>"It looks like we may be entering an even worse stage," said Surono, a state volcanologist, who'd earlier said a week of continual eruptions appeared to be easing pressure behind the magma dome lodged in the Mount Merapi's crater. "We have no idea what's happening now."</p>
<p>The volcano, one of the world's most active, has erupted many times in the last century, often with deadly results.</p>
<p>Forty people have died since it burst back to life just over a week ago — almost all of them from the first, Oct. 26 blast, and subsequent chaotic evacuations. In 1994, 60 people were killed, while in 1930, more than a dozen villages were torched, leaving up to 1,300 dead.</p>
<p>But as with almost all the blueish-gray volcanoes jetting from the landscape in this seismically charged country, tens of thousands of people live on the mountain's rolling slopes. They are drawn to soil made fertile by generations of molten lava and volcanic debris.</p>
<p>More than 70,000 are now packed in crowded government camps well away from the base and may have to stay for weeks, or possibly months.</p>
<p>As rocks and ash rained from the sky, soldiers helped load thousands of frightened villagers into trucks Thursday, including those seeking shelter in three crowded emergency shelters near the foot of the 9,700-foot (3,000-meter) -mountain.</p>
<p>They wound down the mountain, rattling past checkpoints of camouflaged soldiers and police. Elsewhere, several abandoned homes were charred by the latest heat blasts and dozens of carcasses of incinerated cattle littered the scorched flanks.</p>
<p>There have been more than a dozen strong eruptions at Merapi in the last week and thousands of volcanic tremors and ash bursts, temporarily forcing shut nearby airports and — in recent days — prompting officials to close air routes affected by the ash.</p>
<p>With no winds Thursday, ash shot a spectacular 20,000 feet (6,000 meters) into the sky.</p>
<p>It appeared unlikely, however, a Qantas plane forced to make an emergency landing after one of its four engines failed over Batam, an Indonesian island 800 miles (1,400 kilometers) to the west, was tied to the smoldering mountain.</p>
<p>Mount Merapi's danger zone was widened Wednesday from six miles to nine miles (10 to 15 kilometers) from the peak, because of the heightened threat. Even so, dozens of villagers displaced by the disaster took advantage of brief lull in activity Thursday afternoon to head back up the mountain to check on their livestock.</p>
<p>"We are really scared, but we have to feed our cattle," said Sukadi, a 48-year-old farmer, as he brought grass to Boyong, his village six miles (nine kilometers) from the crater.</p>
<p>"We're just going quickly," added Semin, 54, his friend. "We'll head back to the camp as soon as we're done... our families are there."</p>
<p>Indonesia, a vast archipelago of 235 million people, is prone to earthquakes and volcanos because it sits along the Pacific "Ring of Fire," a horseshoe-shaped string of faults that lines the Pacific.</p>
<p>The volcano's initial Oct. 26 blast occurred less than 24 hours after a towering tsunami slammed into the remote Mentawai islands on the western end of the country, sweeping entire villages to sea and killing at least 428 people.</p>
<p>There, too, thousands of people were displaced, many living in government camps.
</p><p>
___
</p><p>
Associated Press writers Irwan Firdaus, Ali Kotarumalos and Niniek Karmini contributed to this report from Jakarta.</p>
</div>
<div class="yn-share-social">Follow Yahoo! News on <a class="twitter" href="http://twitter.com/yahoonews">Twitter</a>, become a fan on <a class="facebook" href="http://www.facebook.com/yahoonews">Facebook</a></div>

</div>
Quote Reply
Re: [nir] clean html In reply to
Ok, and before the change to the global - what is the output?

I'm wondering if its worth trying this instead:

Code:
$content =~ s/[\n\r]+/ /sig;

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] clean html In reply to
TahnksWink, Thanks, it works just like it should