HTML entities on a C1 Page

Topics: General, Visual editor, XSLT
Jun 7, 2011 at 11:31 PM

I'm trying to output html entities ( like © ® – & etc. ) into a C1 page, but unfortunately, when the C1 Page parses the Xhtml in the Content it takes exception to the ampersand "&" character which is not valid and doesn't let me save it. If I use & it will allow me to save, but then the browser doesn't recognize it as an html entity ( For ® it will output ® instead of ® )

If I use <![CDATA[&reg;]]> it will not show on the page (as the C1 parser ignores it).

I tried to use disable-output-escaping but of course, since it's xHTML, it doesn't work.

Can anyone help me with a way to use HTML entities on a C1 Page?

Coordinator
Jun 7, 2011 at 11:39 PM

Use numeric entities, like &#174; for ® or use the actual ® sign.

This limitation is because we treat your markup as XML and we do not load the entity references defined for HTML 4, so you need to be 'strictly XML', requiring you to either use the actual character or the numeric entity. We avoid a whole lot of drama by running vanilla XML.

I found a table mapping html character entities to their numeric values here: http://www.faqs.org/docs/htmltut/characterentities_famsupp_69.html

Jun 10, 2011 at 9:04 AM

Thanks maw. Maybe a nice thing to add on save would be to do a search and replace for common html entities used by designers. &amp; &mdash; &ndash; &lquot; &rquot; come to mind.

Coordinator
Jun 10, 2011 at 9:07 AM

Excellent idea - I will bring this forward in the core group. Thanks!

Jul 4, 2011 at 10:27 PM
Edited Jul 4, 2011 at 10:35 PM

Another thing that I noticed (and probably related) is that if I have something enclosed in CDATA, it sees the "&" and converts it to &amp; If my understanding of CDATA is correct, there should be NO processing on this at all, right?

 

The following jQuery, which simply outputs the facebook feed of our site:

 

<script type="text/javascript">
         <![CDATA[
          $('#fbticker').rssfeed('http://www.facebook.com/feeds/page.php?id=137977022924629&format=rss20',{}, function(e) {
            $(e).find('div.rssBody').vTicker({ showItems: 1}); 
          });     
         ]]>   
</script>

 

Gets turned into:

 

<script type="text/javascript"> 
         
          $('#fbticker').rssfeed('http://www.facebook.com/feeds/page.php?id=137977022924629&amp;format=rss20',{}, function(e) {
            $(e).find('div.rssBody').vTicker({ showItems: 1}); 
          });     
            
</script>

Normally, i'd say this is fine... however, Facebook ([sarcasm]ahhh, wonderful facebook[/sarcasm]) doesn't accept the second URL because of the &amp; in the URL: http://www.facebook.com/feeds/page.php?id=137977022924629&amp;format=rss20

 

Is there a way to tell Composite C1 to simply completely ignore something and just output it to the page?

Coordinator
Jul 5, 2011 at 8:56 AM

Hi @atomiton

The following construction will "survive" xslt transformations

// <xsl:comment>     <![CDATA[

          $('#fbticker').rssfeed('http://www.facebook.com/feeds/page.php?id=137977022924629&format=rss20',{}, function(e) {
            $(e).find('div.rssBody').vTicker({ showItems: 1}); 
          });     
         

]]> // </xsl:comment>

Aug 23, 2012 at 1:03 PM
Edited Aug 23, 2012 at 1:04 PM

Hello,

I have almost a similar issue with RSS Reader package, the flow I receive contains some special char writen like this 

&#8217;

and in my page it's not nice. is there a way to make the RSS Reader rendering this encoded caracter ? Because it should a single quote.

Thanks in advance for your help.

Oct 11, 2012 at 3:16 PM
Edited Oct 11, 2012 at 3:39 PM

I am experiencing the same issue with the RSS Reader.

The raw description field from my RSS feed looks like this:

<description><![CDATA[Some sample text with &#8220;left and right quotes&#8221; isn&#8217;t behaving properly]]></description>

But in the preview window of RSSReader in the results from LoadUrl (and then on my actual page where the rss reader is called) the html entities are getting each & parsed into &amp; so they look like this:

<description>Some sample text with &amp;#8220;left and right quotes&amp;#8221; isn&amp;#8217;t behaving properly</description>

I have verified that running the raw LoadUrl function keeps the CDATA intact, but it's missing from the results feed in the calling RssReader function results.

Is there a way to address this?

Thanks!

BC