Revision: 6174
Updated Code
at May 3, 2008 14:03 by evanwalsh
Updated Code
<?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){
$paragraphs = explode("\n\n", $text);
$output = null;
foreach($paragraphs as $paragraph) {
$output .= "\n<p>".$paragraph."</p>\n";
}
return $output;
}
function textile($text = null){
$regex = array(
'/(.+)\n(.+)/',
'/\*([^\*]+)\*/',
'/\_([^\*]+)\_/',
'/(!)((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))(!)/',
'/(")(.*?)(").*?((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))/',
);
$replace = array(
"$1<br/>$2",
"<strong>$1</strong>",
"<em>$1</em>",
"<img src=\"$2\"/>",
"<a href=\"$4\" title=\"$2\">$2</a>",
);
return preg_replace($regex,$replace,$text);
}
function process($text){
$text = $this->paragraph($text);
$text = $this->textile($text);
return $text;
}
}
?>
Revision: 6173
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 3, 2008 14:01 by evanwalsh
Initial Code
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
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){
$paragraphs = explode("\n\n", $text);
$output = null;
foreach($paragraphs as $paragraph) {
$output .= "\n<p>".$paragraph."</p>\n";
}
return $output;
}
function textile($text = null){
$regex = array(
'/(.+)\n(.+)/',
'/\*([^\*]+)\*/',
'/\_([^\*]+)\_/',
'/(!)((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))(!)/',
'/(")(.*?)(").*?((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))/',
);
$replace = array(
"$1<br/>$2",
"<strong>$1</strong>",
"<em>$1</em>",
"<img src=\"$2\"/>",
"<a href=\"$4\" title=\"$2\">$2</a>",
);
return preg_replace($regex,$replace,$text);
}
function process($text){
$text = $this->paragraph($text);
$text = $this->textile($text);
return $text;
}
}
?>
Initial URL
http://nothingconcept.com
Initial Description
This is a version of Textile that only accepts paragraps, bold, italics, links, and images. Enjoy.
Initial Title
Mini Textile class
Initial Tags
class, html
Initial Language
PHP