[mv_stripHTML]

Description

Link: [mv_stripHTML]
Author: Marc Vos
Category: Custom Tag
Version: 8.5.x
License: Public Domain
Posted: Nov. 27, 2008
Updated: Aug. 03, 2009
More by this author...

Strips all HTML tags from a string.

Parameters

-str string, required The HTML code to be stripped
-tr2nl boolean, optional Translate </TR> to new line

Sample Usage

mv_stripHTML($stringvar, -encodeNONE)
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Strips all HTML from a string.
// Usage example : mv_stripHTML($text, -encodeNONE);
define_tag('mv_stripHTML', -required='str', -copy, -optional='tr2nl');
	local('s' = #str);
	local('tr' = #tr2nl);

	// Replace all </p> with newlines
	#s = string_replaceregexp(#s, -find='<\\/[p|P]>', -replace='\n\n');

	if(#tr == true);
		// Replace all </tr> with newlines
		#s = string_replaceregexp(#s, -find='<\\/[t|T][r|R]>', -replace='\n');
	/if;
	
	// Replace all HTML tag matches with the empty string
	#s = string_replaceregexp(#s, -find='<(.|\n)+?>', -replace='');
  
	// Replace all < and > with < and >
	#s = string_replace(#s, -find='<', -replace='<');
	#s = string_replace(#s, -find='>', -replace='>');

	return(#s);
/define_tag;

 

Comments

03/29/2010, Dominique Guardiola
Solved
OK, the tag is fine, it's just this microsoft html tags crap again through FCkEditor....
03/29/2010, Dominique Guardiola
Does not work everywhere ???
I really dont' get it but have no time to investigate : works on my dev machine but crashes the lasso site on the prod server...
08/22/2009, Dominique Guardiola
tr2nl not really optional
Just modify line 5 : local_defined('tr2nl') ? local('tr' = #tr2nl) | local('tr' = false);
Email:


Password:



Newest

Most Popular

Support tagSwap.net