display xml without it being escaped

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
Definity
Propeller Head
Posts: 10
Joined: Mon Oct 26, 2009 7:59 am

display xml without it being escaped

Post by Definity »

Hi All,

Want to display some code on a page and prevent Flare from escaping it so users can cut n' paste it just as it appears.

Actually want to do something like phpBB does with Code tag.

Ideas?

Cheers,
Kirk


I put his in a blockquote...

<div name="mediaspace" id="mediaspace">
</div>
<p>
<script type="text/javascript" src="../../Resources/PlayerWMA/silverlight.js">
</script>
<script type="text/javascript" src="../../Resources/PlayerWMA/wmvplayer.js">
</script>
<script type="text/javascript">/*<![CDATA[*/ var cnt = document.getElementById("mediaspace");
var src = '../../Resources/PlayerWMA/wmvplayer.xaml';
var cfg = {
file:'../../Resources/WMAvideos/INSERT_FILE_NAME_HERE.wmv',
width:'660',
height:'500',
usefullscreen:'false',
overstretch:'fit',
};
var ply = new jeroenwijering.Player(cnt,src,cfg);/*]]>*/</script>
</p>

and Flare escapes it to this...

<blockquote class="democode">
<p><div name="mediaspace" id="mediaspace"></div></p>
<p><p></p>
<p><script type="text/javascript" src="../../Resources/PlayerWMA/silverlight.js"></p>
<p></script></p>
<p><script type="text/javascript" src="../../Resources/PlayerWMA/wmvplayer.js"></p>
<p></script></p>
<p><script type="text/javascript">/*<![CDATA[*/ var cnt = document.getElementById("mediaspace");</p>
<p>var src = '../../Resources/PlayerWMA/wmvplayer.xaml';</p>
<p>var cfg = {</p>
<p>file:'../../Resources/WMAvideos/INSERT_FILE_NAME_HERE.wmv',</p>
<p>width:'660',</p>
<p>height:'500',</p>
<p>usefullscreen:'false',</p>
<p>overstretch:'fit',</p>
<p>};</p>
<p>var ply = new jeroenwijering.Player(cnt,src,cfg);/*]]>*/</script></p>
<p></p></p>
</blockquote>
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: display xml without it being escaped

Post by LTinker68 »

I believe the <pre>... </pre> tag set is the one you want to use.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
NorthEast
Master Propellus Maximus
Posts: 6372
Joined: Mon Mar 05, 2007 8:33 am

Re: display xml without it being escaped

Post by NorthEast »

Using a pre tag won't make any difference.

I'm not sure I understand what the problem is though, as the Flare code you've included there does actually copy and paste correctly.
If you manually select copy and paste the code from the HTML page it will appear exactly as in your first example.

Are you using some script on your page that extracts the actual underlying HTML code and puts that on the clipboard?
Definity
Propeller Head
Posts: 10
Joined: Mon Oct 26, 2009 7:59 am

Re: display xml without it being escaped

Post by Definity »

Problem is when you copy code snippets from pages < > are escaped out (cut n paste). Needed to allow users to cut n paste reuse code snippets in orig. format without any changes.

Here's my work around... using a form w/ script that doesn't escape chars plus users can simply click button to highlight and copy text (in IE only, Firefox won't allow copy part due to security).

We're still evaluating the Flare for our project but you can see how this works here...

http://www.nicoproductions.com/definity ... 0Topic.htm

Cheers,
Kirk

Code: Select all

			<p>
				<form name="video_popup_call_code">
					<script type="text/javascript">/*<![CDATA[*/function copyit(theField) {
						var tempval=eval("document."+theField)
						tempval.focus()
						tempval.select()
						therange=tempval.createTextRange()
						therange.execCommand("Copy")
					}/*]]>*/</script>
					<input type="button" value="Copy the Video Popup Call Code" name="cpy" onclick="copyit('video_popup_call_code.select1');" />
					<p><textarea name="select1" rows="3" cols="80">
<p>
<a href="../Videos/proposal_catalog_001.htm" onClick="javascript:window.open('../Videos/proposal_catalog_001.htm',null,'width=660,height=500,resizable=no');return false"><img src="../../Resources/Images/video.jpg" /></a>
</p>
						</textarea>
					</p>
				</form>
			</p>
NorthEast
Master Propellus Maximus
Posts: 6372
Joined: Mon Mar 05, 2007 8:33 am

Re: display xml without it being escaped

Post by NorthEast »

Definity wrote:Problem is when you copy code snippets from pages < > are escaped out (cut n paste). Needed to allow users to cut n paste reuse code snippets in orig. format without any changes.
Still not sure I follow, as it does work for a manual copy and paste; copying from IE and pasting into notepad, you get the < > characters - not < and > .

I can see doing it using a script is different though; presumably your script copies the underlying HTML code, not what is rendered on the page.
Anyway, glad it works.
Definity
Propeller Head
Posts: 10
Joined: Mon Oct 26, 2009 7:59 am

Re: display xml without it being escaped

Post by Definity »

Hey Dave,

I wanted to display code snippets without < > being escaped in underlying page code. Yes the text can be rendered in a browser with proper < > displayed but when you use cut n' paste the source page (that's escaped) is copied to the buffer NOT what may be displayed in browser.

So if you take the following code (using any tagging of your choice) and paste it into a topic and build the page it's treated as a script by the compiler and isn't displayed as viewable text (that you can cut n' paste without < > escaped).

Code: Select all

		<p>
			<script type="text/javascript">/*<![CDATA[*/function copyit(theField) {
				var tempval=eval("document."+theField)
				tempval.focus()
				tempval.select()
				therange=tempval.createTextRange()
				therange.execCommand("Copy")
			}/*]]>*/</script></p>
Cheers,
Kirk
KevinDAmery
Propellus Maximus
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: display xml without it being escaped

Post by KevinDAmery »

I concur with Lisa: put pre tags around it. That should stop it from running as a script.
Until next time....
Image
Kevin Amery
Certified MAD for Flare
Andrew
Propellus Maximus
Posts: 1237
Joined: Fri Feb 10, 2006 5:37 am

Re: display xml without it being escaped

Post by Andrew »

Technically, I think the correct XML method is to use a "CDATA" tag (<![CDATA[content content content ]]>), though I don't know if that works properly in Flare. It may be simpler to use <pre>.
Last edited by Andrew on Sun Nov 29, 2009 6:35 am, edited 1 time in total.
Flare v6.1 | Capture 4.0.0
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: display xml without it being escaped

Post by LTinker68 »

CDATA is used a lot in Flare -- it'll insert the tag itself sometimes. I don't know if there's a way to insert it easily yourself, though -- I've only ever seen it when looking at the topic code. I don't remember ever seeing it pop up as an option in any menu.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Post Reply