Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_textile
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19080
Modified Files:
serendipity_event_textile.php textile.php
Log Message:
Had to change the textile function name scope, as this was causing a mess
with (my ;) embedded blog. A textile class would be much better, though.
Index: serendipity_event_textile.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_textile/serendipity_event_textile.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_event_textile.php 26 Feb 2004 11:29:11 -0000 1.1
+++ serendipity_event_textile.php 26 Feb 2004 12:57:39 -0000 1.2
@@ -1,6 +1,6 @@
<?php # $Id$
-require_once dirname(__FILE__) . '/textile.php';
+require_once $serentipity['serendipityHTTPPath'] . 'plugins/serendipity_event_textile/textile.php';
switch ($serendipity['lang']) {
case 'de':
Index: textile.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_textile/textile.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- textile.php 26 Feb 2004 11:29:11 -0000 1.1
+++ textile.php 26 Feb 2004 12:57:39 -0000 1.2
@@ -185,27 +185,27 @@
if (get_magic_quotes_gpc()==1)
$text = stripslashes($text);
- $text = incomingEntities($text);
- $text = encodeEntities($text);
- $text = fixEntities($text);
- $text = cleanWhiteSpace($text);
+ $text = textile_incomingEntities($text);
+ $text = textile_encodeEntities($text);
+ $text = textile_fixEntities($text);
+ $text = textile_cleanWhiteSpace($text);
- $text = getRefs($text);
+ $text = textile_getRefs($text);
- $text = noTextile($text);
- $text = image($text);
- $text = links($text);
- $text = code($text);
- $text = span($text);
- $text = superscript($text);
- $text = footnoteRef($text);
- $text = glyphs($text);
- $text = retrieve($text);
+ $text = textile_noTextile($text);
+ $text = textile_image($text);
+ $text = textile_links($text);
+ $text = textile_code($text);
+ $text = textile_span($text);
+ $text = textile_superscript($text);
+ $text = textile_footnoteRef($text);
+ $text = textile_glyphs($text);
+ $text = textile_retrieve($text);
if ($lite=='') {
- $text = lists($text);
- $text = table($text);
- $text = block($text);
+ $text = textile_lists($text);
+ $text = textile_table($text);
+ $text = textile_block($text);
}
/* clean up <notextile> */
@@ -220,7 +220,7 @@
}
// -------------------------------------------------------------
- function pba($in,$element="") // "parse block attributes"
+ function textile_pba($in,$element="") // "parse block attributes"
{
global $hlgn,$vlgn,$clas,$styl,$cspn,$rspn,$a,$s,$c;
@@ -283,19 +283,19 @@
}
// -------------------------------------------------------------
- function table($text)
+ function textile_table($text)
{
global $a,$c,$s;
$text = $text."\n\n";
return preg_replace_callback("/^(?:table(_?$s$a$c)\. ?\n)?^($a$c\.? ?\|.*\|)\n\n/smU",
- "fTable",$text);
+ "textile_fTable",$text);
}
// -------------------------------------------------------------
- function fTable($matches)
+ function textile_fTable($matches)
{
global $s,$a,$c;
- $tatts = pba($matches[1],'table');
+ $tatts = textile_pba($matches[1],'table');
foreach(preg_split("/\|$/m",$matches[2],-1,PREG_SPLIT_NO_EMPTY) as $row){
if (preg_match("/^($a$c\. )(.*)/m",$row,$rmtch)) {
@@ -322,14 +322,14 @@
// -------------------------------------------------------------
- function lists($text)
+ function textile_lists($text)
{
global $a,$c;
- return preg_replace_callback("/^([#*]+$c .*)$(?![^#*])/smU","fList",$text);
+ return preg_replace_callback("/^([#*]+$c .*)$(?![^#*])/smU","textile_fList",$text);
}
// -------------------------------------------------------------
- function fList($m)
+ function textile_fList($m)
{
global $a,$c;
$text = explode("\n",$m[0]);
@@ -340,8 +340,8 @@
$nl = preg_replace("/^([#*]+)\s.*/","$1",$nextline);
if(!isset($lists[$tl])){
$lists[$tl] = true;
- $atts = pba($atts);
- $line = "\t<".lT($tl)."l$atts>\n\t<li>".$content;
+ $atts = textile_pba($atts);
+ $line = "\t<".textile_lT($tl)."l$atts>\n\t<li>".$content;
} else {
$line = "\t\t<li>".$content;
}
@@ -365,13 +365,13 @@
}
// -------------------------------------------------------------
- function lT($in)
+ function textile_lT($in)
{
return preg_match("/^#+/",$in) ? 'o' : 'u';
}
// -------------------------------------------------------------
- function block($text)
+ function textile_block($text)
{
global $a,$c;
@@ -389,7 +389,7 @@
foreach($find as $tag){
$line = ($pre==false)
? preg_replace_callback("/^($tag)($a$c)\.(?::(\S+))? (.*)$/",
- "fBlock",$line)
+ "textile_fBlock",$line)
: $line;
}
@@ -404,12 +404,12 @@
}
// -------------------------------------------------------------
- function fBlock($m)
+ function textile_fBlock($m)
{
# dump($m);
list(,$tag,$atts,$cite,$content) = $m;
- $atts = pba($atts);
+ $atts = textile_pba($atts);
if(preg_match("/fn(\d+)/",$tag,$fns)){
$tag = 'p';
@@ -421,7 +421,7 @@
$end = "</$tag>";
if ($tag=="bq") {
- $cite = checkRefs($cite);
+ $cite = textile_checkRefs($cite);
$cite = ($cite!='') ? ' cite="'.$cite.'"' : '';
$start = "\t<blockquote$cite>\n\t\t<p";
$end = "</p>\n\t</blockquote>";
@@ -432,7 +432,7 @@
// -------------------------------------------------------------
- function span($text)
+ function textile_span($text)
{
global $c,$pnct;
$qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~');
@@ -447,13 +447,13 @@
([[:punct:]]*)
$f
(?=[])}]|[[:punct:]]+|\s|$)
- /xmU","fSpan",$text);
+ /xmU","textile_fSpan",$text);
}
return $text;
}
// -------------------------------------------------------------
- function fSpan($m)
+ function textile_fSpan($m)
{
# dump($m);
global $c;
@@ -470,14 +470,14 @@
list(,$tag,$atts,$cite,$content,$end) = $m;
$tag = $qtags[$tag];
- $atts = pba($atts);
+ $atts = textile_pba($atts);
$atts.= ($cite!='') ? 'cite="'.$cite.'"' : '';
return "<$tag$atts>$content$end</$tag>";
}
// -------------------------------------------------------------
- function links($text)
+ function textile_links($text)
{
global $c;
return preg_replace_callback('/
@@ -492,20 +492,20 @@
(\/)? # $slash
([^\w\/;]*) # $post
(?=\s|$)
- /Ux',"fLink",$text);
+ /Ux',"textile_fLink",$text);
}
// -------------------------------------------------------------
- function fLink($m)
+ function textile_fLink($m)
{
list(,$pre,$atts,$text,$title,$url,$slash,$post) = $m;
- $url = checkRefs($url);
+ $url = textile_checkRefs($url);
- $atts = pba($atts);
+ $atts = textile_pba($atts);
$atts.= ($title!='') ? ' title="'.$title.'"' : '';
- $atts = ($atts!='') ? shelve($atts) : '';
+ $atts = ($atts!='') ? textile_shelve($atts) : '';
if ($text=='_') {
$text = $url;
@@ -520,14 +520,14 @@
}
// -------------------------------------------------------------
- function getRefs($text)
+ function textile_getRefs($text)
{
return preg_replace_callback("/(?<=^|\s)\[(.+)\]((?:http:\/\/|\/)\S+)(?=\s|$)/U",
- "refs",$text);
+ "textile_refs",$text);
}
// -------------------------------------------------------------
- function refs($m)
+ function textile_refs($m)
{
list(,$flag,$url) = $m;
$GLOBALS['urlrefs'][$flag] = $url;
@@ -535,14 +535,14 @@
}
// -------------------------------------------------------------
- function checkRefs($text)
+ function textile_checkRefs($text)
{
global $urlrefs;
return (isset($urlrefs[$text])) ? $urlrefs[$text] : $text;
}
// -------------------------------------------------------------
- function image($text)
+ function textile_image($text)
{
global $c;
return preg_replace_callback("/
@@ -556,21 +556,21 @@
\! # closing
(?::(\S+))? # optional href
(?=\s|$) # lookahead: space or end of string
- /Ux","fImage",$text);
+ /Ux","textile_fImage",$text);
}
// -------------------------------------------------------------
- function fImage($m)
+ function textile_fImage($m)
{
list(,$algn,$atts,$url) = $m;
- $atts = pba($atts);
- $atts.= ($algn!='') ? ' align="'.iAlign($algn).'"' : '';
+ $atts = textile_pba($atts);
+ $atts.= ($algn!='') ? ' align="'.textile_iAlign($algn).'"' : '';
$atts.= (isset($m[4])) ? ' title="'.$m[4].'"' : '';
$size = @getimagesize($url);
if($size) $atts.= " $size[3]";
- $href = (isset($m[5])) ? checkRefs($m[5]) : '';
- $url = checkRefs($url);
+ $href = (isset($m[5])) ? textile_checkRefs($m[5]) : '';
+ $url = textile_checkRefs($url);
$out = '';
$out.= ($href!='') ? '<a href="'.$href.'">' : '';
@@ -581,7 +581,7 @@
}
// -------------------------------------------------------------
- function code($text)
+ function textile_code($text)
{
global $pnct;
return preg_replace_callback("/
@@ -593,11 +593,11 @@
(?:$|([\]}])|
(?=[[:punct:]]{1,2}|
\s)) # 4 closing bracket?
- /Ux","fCode",$text);
+ /Ux","textile_fCode",$text);
}
// -------------------------------------------------------------
- function fCode($m)
+ function textile_fCode($m)
{
list(,$before,$lang,$code,$after) = $m;
$lang = ($lang!='') ? ' language="'.$lang.'"' : '';
@@ -605,14 +605,14 @@
}
// -------------------------------------------------------------
- function shelve($val)
+ function textile_shelve($val)
{
$GLOBALS['shelf'][] = $val;
return ' <'.count($GLOBALS['shelf']).'>';
}
// -------------------------------------------------------------
- function retrieve($text)
+ function textile_retrieve($text)
{
global $shelf;
$i = 0;
@@ -626,7 +626,7 @@
}
// -------------------------------------------------------------
- function incomingEntities($text)
+ function textile_incomingEntities($text)
{
/* turn any incoming ampersands into a dummy character for now.
This uses a negative lookahead for alphanumerics followed by a semicolon,
@@ -636,7 +636,7 @@
}
// -------------------------------------------------------------
- function encodeEntities($text)
+ function textile_encodeEntities($text)
{
/* Convert high and low ascii to entities. If multibyte string functions are
available (on by default in php 4.3+), we convert using unicode mapping as
@@ -644,12 +644,12 @@
built-in htmlentities() */
return (function_exists('mb_encode_numericentity'))
- ? encode_high($text)
+ ? textile_encode_high($text)
: htmlentities($text,ENT_NOQUOTES,"utf-8");
}
// -------------------------------------------------------------
- function fixEntities($text)
+ function textile_fixEntities($text)
{
/* de-entify any remaining angle brackets or ampersands */
return str_replace(array(">", "<", "&"),
@@ -657,7 +657,7 @@
}
// -------------------------------------------------------------
- function cleanWhiteSpace($text)
+ function textile_cleanWhiteSpace($text)
{
$out = str_replace(array("\r\n","\t"), array("\n",''), $text);
$out = preg_replace("/\n{3,}/","\n\n",$out);
@@ -667,27 +667,27 @@
}
// -------------------------------------------------------------
- function noTextile($text)
+ function textile_noTextile($text)
{
return preg_replace('/(^|\s)==(.*)==(\s|$)?/msU',
'$1<notextile>$2</notextile>$3',$text);
}
// -------------------------------------------------------------
- function superscript($text)
+ function textile_superscript($text)
{
return preg_replace('/\^(.*)\^/mU','<sup>$1</sup>',$text);
}
// -------------------------------------------------------------
- function footnoteRef($text)
+ function textile_footnoteRef($text)
{
return preg_replace('/\b\[([0-9]+)\](\s)?/U',
'<sup><a href="#fn$1">$1</a></sup>$2',$text);
}
// -------------------------------------------------------------
- function glyphs($text)
+ function textile_glyphs($text)
{
// fix: hackish
$text = preg_replace('/"\z/',"\" ", $text);
@@ -754,7 +754,7 @@
}
// -------------------------------------------------------------
- function iAlign($in)
+ function textile_iAlign($in)
{
$vals = array(
'<'=>'left',
@@ -764,7 +764,7 @@
}
// -------------------------------------------------------------
- function hAlign($in)
+ function textile_hAlign($in)
{
$vals = array(
'<'=>'left',
@@ -775,7 +775,7 @@
}
// -------------------------------------------------------------
- function vAlign($in)
+ function textile_vAlign($in)
{
$vals = array(
'^'=>'top',
@@ -785,21 +785,21 @@
}
// -------------------------------------------------------------
- function encode_high($text,$charset="UTF-8")
+ function textile_encode_high($text,$charset="UTF-8")
{
- $cmap = cmap();
+ $cmap = textile_cmap();
return mb_encode_numericentity($text, $cmap, $charset);
}
// -------------------------------------------------------------
- function decode_high($text,$charset="UTF-8")
+ function textile_decode_high($text,$charset="UTF-8")
{
- $cmap = cmap();
+ $cmap = textile_cmap();
return mb_decode_numericentity($text, $cmap, $charset);
}
// -------------------------------------------------------------
- function cmap()
+ function textile_cmap()
{
$f = 0xffff;
$cmap = array(
@@ -881,7 +881,7 @@
}
// -------------------------------------------------------------
- function txtgps($thing)
+ function textile_txtgps($thing)
{
if (isset($_POST[$thing])){
if (get_magic_quotes_gpc()==1){
@@ -901,7 +901,7 @@
// -------------------------------------------------------------
- function detextile($text) {
+ function textile_detextile($text) {
$text = preg_replace("/<br \/>\s*/","\n",$text);
@@ -910,7 +910,7 @@
foreach($oktags as $tag){
$text = preg_replace_callback("/\t*<(".$tag.")\s*([^>]*)>(.*)<\/\\1>/Usi",
- "processTag",$text);
+ "textile_processTag",$text);
}
$glyphs = array(
@@ -960,15 +960,15 @@
$text = preg_replace('/^\t* *p\. /m','',$text);
- return decode_high($text);
+ return textile_decode_high($text);
}
// -------------------------------------------------------------
- function processTag($matches)
+ function textile_processTag($matches)
{
list($all,$tag,$atts,$content) = $matches;
- $a = splat($atts);
+ $a = textile_splat($atts);
# dump($tag); dump($content); dump($a);
$phr = array(
@@ -986,13 +986,13 @@
$blk = array('p','h1','h2','h3','h4','h5','h6');
if(isset($phr[$tag])) {
- return $phr[$tag].sci($a).$content.$phr[$tag];
+ return $phr[$tag].textile_sci($a).$content.$phr[$tag];
} elseif($tag=='blockquote') {
- return 'bq.'.sci($a).' '.$content;
+ return 'bq.'.textile_sci($a).' '.$content;
} elseif(in_array($tag,$blk)) {
- return $tag.sci($a).'. '.$content;
+ return $tag.textile_sci($a).'. '.$content;
} elseif ($tag=='a') {
- $t = filterAtts($a,array('href','title'));
+ $t = textile_filterAtts($a,array('href','title'));
$out = '"'.$content;
$out.= (isset($t['title'])) ? ' ('.$t['title'].')' : '';
$out.= '":'.$t['href'];
@@ -1003,7 +1003,7 @@
}
// -------------------------------------------------------------
- function filterAtts($atts,$ok)
+ function textile_filterAtts($atts,$ok)
{
foreach($atts as $a) {
if(in_array($a['name'],$ok)) {
@@ -1017,7 +1017,7 @@
}
// -------------------------------------------------------------
- function sci($a)
+ function textile_sci($a)
{
$out = '';
foreach($a as $t){
@@ -1030,7 +1030,7 @@
}
// -------------------------------------------------------------
- function splat($attr) // returns attributes as an array
+ function textile_splat($attr) // returns attributes as an array
{
$arr = array();
$atnm = '';
|