Simple Java BBCode Implementation

I have made a simple Java BBCode Implementation, and it is open source and free to use. Feel free to take it into your project.

Below is the Java static method to convert the bbcode-based text into HTML form to be displayed in browser.

public static String bbcode(String text) {

String temp = nl2br(text);

Map<string , String> bbMap = new HashMap</string><string , String>();</string>

bbMap.put(“\\[b\\](.+?)\\[/b\\]”, “<strong>$1</strong>”);

bbMap.put(“\\[i\\](.+?)\\[/i\\]”, “<span style=’font-style:italic;’>$1</span>”);

bbMap.put(“\\[u\\](.+?)\\[/u\\]”, “<span style=’text-decoration:underline;’>$1</span>”);

bbMap.put(“\\[h1\\](.+?)\\[/h1\\]”, “<h1>$1</h1>”);

bbMap.put(“\\[h2\\](.+?)\\[/h2\\]”, “<h2>$1</h2>”);

bbMap.put(“\\[h3\\](.+?)\\[/h3\\]”, “<h3>$1</h3>”);

bbMap.put(“\\[h4\\](.+?)\\[/h4\\]”, “<h4>$1</h4>”);

bbMap.put(“\\[h5\\](.+?)\\[/h5\\]”, “<h5>$1</h5>”);

bbMap.put(“\\[h6\\](.+?)\\[/h6\\]”, “<h6>$1</h6>”);

bbMap.put(“\\[quote\\](.+?)\\[/quote\\]”, “<blockquote>$1</blockquote>”);

bbMap.put(“\\[p\\](.+?)\\[/p\\]”, “<p>$1</p>”);

bbMap.put(“\\[p=(.+?),(.+?)\\](.+?)\\[/p\\]”, “<p style=’text-indent:$1px;line-height:$2%;’>$3</p>”);

bbMap.put(“\\[center\\](.+?)\\[/center\\]”, “<div align=’center’>$1”);

bbMap.put(“\\[align=(.+?)\\](.+?)\\[/align\\]”, “<div align=’$1′>$2”);

bbMap.put(“\\[color=(.+?)\\](.+?)\\[/color\\]”, “<span style=’color:$1;’>$2</span>”);

bbMap.put(“\\[size=(.+?)\\](.+?)\\[/size\\]”, “<span style=’font-size:$1;’>$2</span>”);

bbMap.put(“\\[img\\](.+?)\\[/img\\]”, “<img src=’$1′ />”);

bbMap.put(“\\[img=(.+?),(.+?)\\](.+?)\\[/img\\]”, “<img width=’$1′ height=’$2′ src=’$3′ />”);

bbMap.put(“\\[email\\](.+?)\\[/email\\]”, “<a href=’mailto:$1′>$1</a>”);

bbMap.put(“\\[email=(.+?)\\](.+?)\\[/email\\]”, “<a href=’mailto:$1′>$2</a>”);

bbMap.put(“\\[url\\](.+?)\\[/url\\]”, “<a href=’$1′>$1</a>”);

bbMap.put(“\\[url=(.+?)\\](.+?)\\[/url\\]”, “<a href=’$1′>$2</a>”);

bbMap.put(“\\[video\\](.+?)\\[/video\\]”, “<video src=’$1′ />”);

for (Map.Entry entry: bbMap.entrySet()) {

temp = temp.replaceAll(entry.getKey().toString(), entry.getValue().toString());

}

return temp;

}


6 June 2011
Refer to stackoverflow, there is one topic that is related to Java BBCode I discovered just now.

SmokeScreen Convert Flash into HTML5+JavaScript

SmokeScreen, a project utilize JavaScript and HTML5, to convert Flash into pure HTML5 + JavaScript, therefore user can browser the Flash animation without Flash Plugin.

Chris Smoak, a programmer, recently started a project called SmokeScreen, to convert Flash into pure HTML5 + JavaScript, therefore user can browser the Flash animation without Flash Plugin. Here have some fantastic demo.

SmokeScreen totally run inside the browser, it reads SWF binary file, decrypt it using local JavaScript Online!!!, it retrieves the images and sound data from the SWF, convert them into Base64-encoded data. Then, it converts its vector graphic into SVG animation. We can use Google Chrome to open Web Inspector. During the time the demo running, you can see SVG is running in the real time. SmokeScreen also designed his own ActionScript compiler.

Most importantly, this converted animation can be viewed inside iPad and iPhone as well.

Watch FIFA World Cup 2010 Online

2010 FIFA World Cup Football (which is being played in South Africa) starts from June 11th 2010 and will go on for a month. The final match of the tournament will be played on 11th July 2010.

If you are the person who want to watch it using laptop but not television sets, below are the websites that provide online watching services.

TV Bunch

 

Click Here to Watch

I will also update the links if possible, feel free give some comments and introduction for the other links that provide relevant services.