Markdown Text Filtering for PeopleSoft
I’ve been working on some new tricks for my session at Oracle Open World. A lot of the things I’ve come up with incorporate Web 2.0 buzz word compliant features into the PeopleSoft Portal… stuff like Ajax/DHTML rich client type of features. I’ve also been trying to come up with simple, no-fuss, high-value customizations that our customers can easily implement on their own. One of them is adding Markdown text filtering to the PeopleSoft Portal.
Markdown is a…
“…text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).”
With Markdown, we can write this:
* Bullet 1
* Bullet 2
* Bullet 3
to get this:
<ul> <li>Bullet 1</li> <li>Bullet 2</li> <li>Bullet 3</li> </ul>
This is one of the many things you can do with Markdown. For more examples, visit the Markdown Syntax page.
Markdown is nothing new and has actually been around for since 2003. It was created by the “Mac Pundit” Jon Gruber. I classify Markdown (and other text filtering tools like it… i.e., Textile) as a middle-of-the-road solution between editing HTML by hand and using a WYSIWYG editor. Markdown makes it easy to generate HTML by writting plain-text documents with an intuitively simple text formatting syntax.
So what value does this bring to your PeopleSoft application? Well, in the case of the PeopleSoft Portal, you can have editors edit content without having to know HTML. Earlier releases of the portal did not include a WYSIWYG HTML editor like version 8.9 does, so Markdown is a good alternative for your content authors/editors.
Let’s look at an example
Before we start, to allow for simple and easy integration of Markdown within PeopleSoft, we should use the MarkdownJ library. MarkdownJ is a Java port of Markdown. PeopleSoft can natively call Java within PeopleCode and so utilizing MarkdownJ makes our life a lot easier. To use MarkdownJ, you’ll need the MarkdownJ jar file and Apache Ant. After you’ve downloaded Apache Ant, extract the contents then look for the ant.jar file under the lib directory. Copy both the markdown.jar and ant.jar to your PS_HOME/class directory on your PeopleSoft appserver. You’ll need to cycle your appserver in order to load them into the JVM’s memory.
Once you have the libraries placed on the appserver, all it takes to call MarkdownJ from within PeopleCode is this:
Local JavaObject &markdown = CreateJavaObject("com.petebevin.markdown.MarkdownProcessor");
Local string &transformedText = &markdown.markdown(&someText);
You can take this little bit of code and apply it to any text based process you want. In our example, however, we’ll look at applying Markdown to Pagelet Wizard.
Pagelet Wizard is PeopleSoft’s tool for creating pagelets (or the more widely used term, portlets). It’s a simple three step process:
# Acquire data (Data Types/Sources)
# Transform data (Data Transformations)
# Publish pagelet/portlet
Pagelet Wizard comes with several data types/sources out of the box. One of these is called the HTML data type. With this data type, a user can create a portlet by simply writting HTML within Pagelet Wizard then publishing the contents to a portlet. We’re going to clone the HTML data type as a “Text” data type. To do this, go to
Portal Administration > Pagelets > Pagelet Wizard > Define Data Types > Add
Define your Data Type according to the graphic below:

One thing you won’t be able to specify in the picture above is the CSS_MARKDOWN display format. We’ll have to come back to that later. Data Types define the source of the data you want to acquire for your portlet. When you create a new Tata Type, you’ll need to specify the PeopleCode application class you want to use that will source the data. In this case, our data type is similar to the HTML data type in that we’re sourcing the data directly from user input within Pagelet Wizard in the form of a text area. So, we’re going to just refer to the app class for the HTML data source.
Next, we need to define a Transform Type. Navigate to:
Portal Administration > Pagelets > Pagelet Wizard > Define Transform Types > Add
Again, create a new Transformation Type with the following properties:

A Transformation Type defines a transformation processor. In this case, our transformation processor is MarkdownJ. A Transformation Type requires an app class that will take your Data Type output and convert it to the format you want. In this case, we will have to roll up our sleeves and write a little PeopleCode. For your convenience, here’s a project you can import into your database. And just for reference, here’s what the code in the app class looks like (I cloned the PTPPB_PAGELET:Transformer:PassthroughTransformer class to build the Markdown transformer):
import PTPPB_PAGELET:UTILITY:*;
import PTPPB_PAGELET:Transformer:*;
import PTPPB_PAGELET:*;
/**
* Transformer that performs a Markdown transform.
*/
class MarkdownTransformer extends PTPPB_PAGELET:Transformer:Transformer
method MarkdownTransformer(&ID_param As string);
method execute(&pageletID As string) Returns string;
method Clone() Returns PTPPB_PAGELET:Transformer:Transformer;
end-class;
/**
* Constructor.
*
* @param id_param ID of this object. Should be unique.
*/
method MarkdownTransformer
/+ &ID_param as String +/
%Super = create PTPPB_PAGELET:Transformer:Transformer(&ID_param);
end-method;
/**
* Calls MarkdownJ to process Markdown filtering
*
* @param pageletID ID of the pagelet being executed.
*/
method execute
/+ &pageletID as String +/
/+ Returns String +/
/+ Extends/implements PTPPB_PAGELET:Transformer:Transformer.execute +/
Local JavaObject &markdown = CreateJavaObject("com.petebevin.markdown.MarkdownProcessor");
Local string &transformedText = &markdown.markdown(%This.DataToTransform.Value);
Return &transformedText;
end-method;
/**
* Make an exact copy of this object.
*
* @return Text Exact copy of this object
*/
method Clone
/+ Returns PTPPB_PAGELET:Transformer:Transformer +/
/+ Extends/implements PTPPB_PAGELET:Transformer:Transformer.Clone +/
Return create PTPPB_PAGELET:Transformer:PassthroughTransformer(%This.ID);
end-method;
Lastly, you’ll need to define a new Display Format. Navigate to:
Portal Administration > Pagelets > Pagelet Wizard > Define Display Formats > Add

A Display Format is a subclass of a Transformation Type. For example, an XSL Transformation Type can have a number of Display Types. A few delivered Display Types for XSL are chart, list, table, etc. In our case, we will only have one Display Type with Markdown.
Once you’ve define the Transformation Type and the Display Format, go back into your Markup Data Type page and add the Markup Display Format. The list of Display Formats in the Data Type page allows you to apply other Display Format/Transformation Types to a data source.
Once you’ve done all of that, you can now create a new text based pagelet by selecting the “Text” Data Type. When you get to step 4, select Markdown. At step 5 you’ll see your text after the Markdown transformation is applied.
November 8th, 2005 at 7:40 AM PST
Thanks for posting this article. Although we dont have portal i found it interesting as I am interested in using peoplesoft with HTML and Java technologies.
December 7th, 2005 at 10:49 PM PST
Is there a move to bring PeopleSoft components to use Ajax, or is it just on limited to the Portal? PeopleSoft components and Ajax should mix well together, reducing the need for a workaround such as deferred processing. It certainly would revolutionize the speed and wow-factor of PeopleSoft.
——-
I once did a function for converting some bbcodes to html with the aid of regex JavaObjects. The primary logic is handled by PeopleCode with the matcher groups being returned by the regex API. In most installations, a separate architecture group is in charge of application server administration. Sometimes, people in this group will be reluctant to upload additional java packages in the server.
How big is the performance impact of passing objects around between java and PeopleCode? So far in my component a performance degradation is not really noticeable - well, in comparison to database operations.
October 11th, 2007 at 8:27 PM PDT
Shouldn’t the clone method return a MarkdownTransformer rather than a PTPPB_PAGELET:Transformer:PassthroughTransformer?
This is a very good post Rich and serves as an excellent example of how to create a new Transformer for use with the PeopleSoft Pagelet Wizard.