/ Published in: PHP
This is a version of Textile that only accepts paragraps, bold, italics, links, and images. Enjoy.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php class TextiLite{ /* TextiLite: A lightweight version of Textile built with PHP by Evan Walsh Version 001 Based on the work of: http://codeigniter.com/wiki/BBCode_Helper/ http://codeigniter.com/forums/viewthread/69615/ Supports: <br/> by the way of newline *Text* => <strong>Text</strong> _Text_ => <em>Text</em> !http://image.url! => <img src="http://image.url"/> "Text":http://text.url => <a href="http://text.url" title="Text">Text</a> */ function paragraph($text){ $output = null; foreach($paragraphs as $paragraph) { $output .= "\n<p>".$paragraph."</p>\n"; } return $output; } function textile($text = null){ '/(.+)\n(.+)/', '/\*([^\*]+)\*/', '/\_([^\*]+)\_/', '/(!)((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))(!)/', '/(")(.*?)(").*?((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))/', ); "$1<br/>$2", "<strong>$1</strong>", "<em>$1</em>", "<img src=\"$2\"/>", "<a href=\"$4\" title=\"$2\">$2</a>", ); } function process($text){ $text = $this->paragraph($text); $text = $this->textile($text); return $text; } } ?>
URL: http://nothingconcept.com