Syntax Highlight: a test

When testing new functionality on the blog, I (typically) obscure the actual process of testing. However, there are a few circumstances where this isn’t tenable.

Syntax highlighting is just such a circumstance. It is not sufficient to see how the javascript/plugin solution I’m leveraging works on the blog itself…instead I must also see how it is rendered in RSS feeds and on other sites that syndicate this content.

You may ask why I’m installing a syntax highlighting solution on the blog. The answer is simple. There is a wealth of sample code and unique solutions that I’ve accumulated over the the years of interacting with Software Companies who built commerce solutions leveraging the IP Commerce APIs.

It is, now, time to share this information.

If you are interested in doing something similar to your site, or blog, I’m using a combination of the open source SyntaxHighlighter javascript client side code and a WordPress plugin called SyntaxHighlighter Evolved. I have chosen this set of solutions, not only due to appearance, but also as it should allow for viewing source, copying to clipboard, and printing simply by clicking on the code box as rendered.

Below are a few tests of the syntax highlighting feature…please excuse the testing.

UPDATE: I should note that I don’t expect the code to render in the same fashion via a feed as it does on this page…this is due to the nature of deployment of the solution.

A bit of php/html perhaps?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>PHP Code Example</title>
</head>
<body>
	<h1>PHP Code Example</h1>

	<p><?php echo 'Hello World!'; ?></p>

	<p>This line is highlighted.</p>

	<div class="foobar">
		This	is	an
		example	of	smart
		tabs.
	</div>

	<p><a href="http://wordpress.org/">WordPress</a></p>
</body>
</html>

Some Java?

package helloworldapp;

/**
 * The HelloWorldApp class implements an application that
 * simply prints "Hello World!" to standard output.
 */
public class HelloWorldApp {
    
    /** Creates a new instance of HelloWorldApp */
    public HelloWorldApp() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
    
}

Perhaps some C#?

// Hello2.cs
using System;

public class Hello2
{
   public static void Main()
   {
      Console.WriteLine("Hello, World!");
   }
}

And, finally, a rather lengthy sample of an authorization transaction using the Commerce Web Services REST interfaces that should be collapsed by default requiring a click to expand (at least on this page).

<AuthorizeAndCaptureTransaction xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard/Rest">
     <ApplicationProfileId>#APPID#</ApplicationProfileId>
     <MerchantProfileId>#MERCHID#</MerchantProfileId>
     <ReportingData xmlns:d2p1="http://schemas.ipcommerce.com/CWS/v2.0/Transactions" i:nil="true"/>
     <Transaction xmlns:d2p1="http://schemas.ipcommerce.com/CWS/v2.0/Transactions" xmlns:d2p2="http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard" i:type="d2p2:BankcardTransaction">
          <d2p1:CustomerData>
               <d2p1:BillingData>
                    <d2p1:Name i:nil="true"/>
                    <d2p1:Address>
                         <d2p1:Street1>1400 16th Street</d2p1:Street1>
                         <d2p1:Street2 i:nil="true"/>
                         <d2p1:City>Denver</d2p1:City>
                         <d2p1:StateProvince>CO</d2p1:StateProvince>
                         <d2p1:PostalCode>80202</d2p1:PostalCode>
                         <d2p1:CountryCode>USA</d2p1:CountryCode>
                    </d2p1:Address>
                    <d2p1:BusinessName>AcmeInc</d2p1:BusinessName>
                    <d2p1:Phone i:nil="true"/>
                    <d2p1:Fax i:nil="true"/>
                    <d2p1:Email i:nil="true"/>
               </d2p1:BillingData>
               <d2p1:CustomerId>cust123x</d2p1:CustomerId>
               <d2p1:CustomerTaxId i:nil="true"/>
               <d2p1:ShippingData i:nil="true"/>
          </d2p1:CustomerData>
          <d2p1:ReportingData>
               <d2p1:Comment>COMMENT</d2p1:Comment>
               <d2p1:Description>DESCRIPTION</d2p1:Description>
               <d2p1:Reference>REFERENCE</d2p1:Reference>
          </d2p1:ReportingData>
          <d2p1:Addendum i:nil="true"/>
          <d2p2:ApplicationConfigurationData i:nil="true"/>
          <d2p2:TenderData>
               <d2p1:PaymentAccountDataToken i:nil="true"/>
               <d2p1:SecurePaymentAccountData i:nil="true"/>
               <d2p2:CardData>
                    <d2p2:CardType>Visa</d2p2:CardType>
                    <d2p2:CardholderName>John Doe</d2p2:CardholderName>
                    <d2p2:PAN>4012000033330026</d2p2:PAN>
                    <d2p2:Expire>0409</d2p2:Expire>
                    <d2p2:Track1Data i:nil="true"/>
                    <d2p2:Track2Data>4111111111111111=09041011000012345678</d2p2:Track2Data>
               </d2p2:CardData>
               <d2p2:CardSecurityData>
                    <d2p2:AVSData>
                         <d2p2:CardholderName>Test Cardholder</d2p2:CardholderName>
                         <d2p2:Street>1400 16th Street</d2p2:Street>
                         <d2p2:City>Denver</d2p2:City>
                         <d2p2:StateProvince>CO</d2p2:StateProvince>
                         <d2p2:PostalCode>80203</d2p2:PostalCode>
                         <d2p2:Country>USA</d2p2:Country>
                         <d2p2:Phone i:nil="true"/>
                    </d2p2:AVSData>
                    <d2p2:CVDataProvided>NotSet</d2p2:CVDataProvided>
                    <d2p2:CVData i:nil="true"/>
                    <d2p2:KeySerialNumber i:nil="true"/>
                    <d2p2:PIN i:nil="true"/>
               </d2p2:CardSecurityData>
          </d2p2:TenderData>
          <d2p2:TransactionData>
               <d2p1:Amount>11.00</d2p1:Amount>
               <d2p1:CurrencyCode>USD</d2p1:CurrencyCode>
               <d2p2:AccountType>NotSet</d2p2:AccountType>
               <d2p2:AlternativeMerchantData i:nil="true"/>
               <d2p2:ApprovalCode i:nil="true"/>
               <d2p2:CashBackAmount>0</d2p2:CashBackAmount>
               <d2p2:CustomerPresent>Present</d2p2:CustomerPresent>
               <d2p2:EmployeeId>49</d2p2:EmployeeId>
               <d2p2:EntryMode>TrackDataFromMSR</d2p2:EntryMode>
               <d2p2:GoodsType>NotSet</d2p2:GoodsType>
               <d2p2:IndustryType>Retail</d2p2:IndustryType>
               <d2p2:InternetTransactionData i:nil="true"/>
               <d2p2:InvoiceNumber>545</d2p2:InvoiceNumber>
               <d2p2:OrderNumber>885380</d2p2:OrderNumber>
               <d2p2:SignatureCaptured>false</d2p2:SignatureCaptured>
               <d2p2:TerminalId i:nil="true"/>
               <d2p2:TipAmount>0</d2p2:TipAmount>
          </d2p2:TransactionData>
     </Transaction>
</AuthorizeAndCaptureTransaction> 

Please advise if you see any strange behaviours or unexpected formatting/etc.

July 3, 2010

Leave a Reply

Your email address will not be published. Required fields are marked *