Lines Matching +full:k +full:- +full:lite
4 * Example: get XHTML from a given Textile-markup string ($string)
7 * echo $textile->TextileThis($string);
12 $Id: classTextile.php 216 2006-10-17 22:31:53Z zem $
25 Copyright (c) 2003-2004, Dean Allen <dean@textism.com>
28 Thanks to Carlo Zottmann <carlo@g-blog.net> for refactoring
67 Header: h(1-6).
68 Paragraphs beginning with 'hn. ' (where n is 1-6) are wrapped in header tags.
69 Example: h1. Header... -> <h1>Header...</h1>
72 Example: p. Text -> <p>Text</p>
75 Example: bq. Block quotation... -> <blockquote>Block quotation...</blockquote>
79 -> <blockquote cite="http://textism.com">Text...</blockquote>
81 Footnote: fn(1-100).
82 Example: fn1. Footnote... -> <p id="fn1">Footnote...</p>
94 _emphasis_ -> <em>emphasis</em>
95 __italic__ -> <i>italic</i>
96 *strong* -> <strong>strong</strong>
97 **bold** -> <b>bold</b>
98 ??citation?? -> <cite>citation</cite>
99 -deleted text- -> <del>deleted</del>
100 +inserted text+ -> <ins>inserted</ins>
101 ^superscript^ -> <sup>superscript</sup>
102 ~subscript~ -> <sub>subscript</sub>
103 @code@ -> <code>computer code</code>
104 %(bob)span% -> <span class="bob">span</span>
106 ==notextile== -> leave text alone (do not format)
108 "linktext":url -> <a href="url">linktext</a>
109 "linktext(title)":url -> <a href="url" title="title">linktext</a>
111 !imageurl! -> <img src="imageurl" />
112 !imageurl(alt text)! -> <img src="imageurl" alt="alt text" />
113 !imageurl!:linkurl -> <a href="linkurl"><img src="imageurl" /></a>
115 ABC(Always Be Closing) -> <acronym title="Always Be Closing">ABC</acronym>
141 < -> left align ex. p<. left-aligned para
142 > -> right align h3>. right-aligned header 3
143 = -> centred h4=. centred header 4
144 <> -> justified p<>. justified paragraph
148 ^ -> top ex. |^. top-aligned table cell|
149 - -> middle |-. middle aligned|
150 ~ -> bottom |~. bottom aligned cell|
152 Plain (parentheses) inserted between block syntax and the closing dot-space
155 p(hector). paragraph -> <p class="hector">paragraph</p>
157 p(#fluid). paragraph -> <p id="fluid">paragraph</p>
160 p(hector#fluid). paragraph -> <p class="hector" id="fluid">paragraph</p>
164 p{line-height:18px}. paragraph -> <p style="line-height:18px">paragraph</p>
166 h3{color:red}. header 3 -> <h3 style="color:red">header 3</h3>
170 p[no]. paragraph -> <p lang="no">paragraph</p>
172 %[fr]phrase% -> <span lang="fr">phrase</span>
177 #{color:blue} one -> <ol style="color:blue">
186 -> It goes like this, <span style="color:red">the fourth the fifth</span>
225 var $lite = false; variable in Textile
233 // -------------------------------------------------------------
236 $this->hlgn = "(?:\<(?!>)|(?<!<)\>|\<\>|\=|[()]+(?! ))";
237 $this->vlgn = "[\-^~]";
238 $this->clas = "(?:\([^)]+\))";
239 $this->lnge = "(?:\[[^]]+\])";
240 $this->styl = "(?:\{[^}]+\})";
241 $this->cspn = "(?:\\\\\d+)";
242 $this->rspn = "(?:\/\d+)";
243 $this->a = "(?:{$this->hlgn}|{$this->vlgn})*";
244 $this->s = "(?:{$this->cspn}|{$this->rspn})*";
245 $this->c = "(?:{$this->clas}|{$this->styl}|{$this->lnge}|{$this->hlgn})*";
247 $this->pnct = '[\!"#\$%&\'()\*\+,\-\./:;<=>\?@\[\\\]\^_`{\|}\~]';
248 $this->urlch = '[\w"$\-_.+!*\'(),";\/?:@=&%#{}|\\^~\[\]`]';
250 $this->url_schemes = array('http','https','ftp','mailto');
252 $this->btag = array('bq', 'bc', 'notextile', 'pre', 'h[1-6]', 'fn\d+', 'p');
254 $this->glyph = array(
272 $this->hu = hu;
276 // -------------------------------------------------------------
277 function TextileThis($text, $lite='', $encode='', $noimage='', $strict='', $rel='') argument
279 //echo "\$text is -->".$text."<--<br />";;
281 $this->rel = ' rel="'.$rel.'" ';
282 $this->lite = $lite;
283 $this->noimage = $noimage;
286 $text = $this->incomingEntities($text);
292 $text = $this->cleanWhiteSpace($text);
295 $text = $this->getRefs($text);
297 if (!$lite) {
298 $text = $this->block($text);
301 $text = $this->retrieve($text);
310 // -------------------------------------------------------------
311 function TextileRestricted($text, $lite=1, $noimage=1, $rel='nofollow') argument
313 $this->restricted = true;
314 $this->lite = $lite;
315 $this->noimage = $noimage;
317 $this->rel = ' rel="'.$rel.'" ';
320 $text = $this->encode_html($text, 0);
322 $text = $this->cleanWhiteSpace($text);
323 $text = $this->getRefs($text);
325 if ($lite) {
326 $text = $this->blockLite($text);
329 $text = $this->block($text);
332 $text = $this->retrieve($text);
340 // -------------------------------------------------------------
359 if (preg_match("/($this->vlgn)/", $matched, $vert))
360 $style[] = "vertical-align:" . $this->vAlign($vert[1]) . ";";
379 $style[] = "padding-left:" . strlen($pl[1]) . "em;";
384 // $this->dump($pr);
385 $style[] = "padding-right:" . strlen($pr[1]) . "em;";
389 if (preg_match("/($this->hlgn)/", $matched, $horiz))
390 $style[] = "text-align:" . $this->hAlign($horiz[1]) . ";";
397 if ($this->restricted)
412 // -------------------------------------------------------------
421 // -------------------------------------------------------------
425 …return preg_replace_callback("/^(?:table(_?{$this->s}{$this->a}{$this->c})\. ?\n)?^({$this->a}{$th…
429 // -------------------------------------------------------------
432 $tatts = $this->pba($matches[1], 'table');
434 foreach(preg_split("/\|$/m", $matches[2], -1, PREG_SPLIT_NO_EMPTY) as $row) {
435 if (preg_match("/^($this->a$this->c\. )(.*)/m", ltrim($row), $rmtch)) {
436 $ratts = $this->pba($rmtch[1], 'tr');
444 if (preg_match("/^(_?$this->s$this->a$this->c\. )(.*)/", $cell, $cmtch)) {
445 $catts = $this->pba($cmtch[1], 'td');
449 $cell = $this->graf($this->span($cell));
460 // -------------------------------------------------------------
463 … return preg_replace_callback("/^([#*]+$this->c .*)$(?![^#*])/smU", array(&$this, "fList"), $text);
466 // -------------------------------------------------------------
472 if (preg_match("/^([#*]+)($this->a$this->c) (.*)$/s", $line, $m)) {
479 $atts = $this->pba($atts);
480 $line = "\t<" . $this->lT($tl) . "l$atts>\n\t\t<li>" . $this->graf($content);
482 $line = "\t\t<li>" . $this->graf($content);
486 foreach(array_reverse($lists) as $k => $v) {
487 if(strlen($k) > strlen($nl)) {
488 $line .= "\n\t</" . $this->lT($k) . "l>";
489 if(strlen($k) > 1)
491 unset($lists[$k]);
500 // -------------------------------------------------------------
506 // -------------------------------------------------------------
512 // -------------------------------------------------------------
519 // -------------------------------------------------------------
522 $find = $this->btag;
532 if (preg_match("/^($tre)($this->a$this->c)\.(\.?)(?::(\S+))? (.*)$/s", $line, $m)) {
535 $out[count($out)-1] .= $c1;
538 … list($o1, $o2, $content, $c2, $c1) = $this->fBlock(array(0,$tag,$atts,$ext,$cite,$graf));
550 … list($o1, $o2, $content, $c2, $c1) = $this->fBlock(array(0,$tag,$atts,$ext,$cite,$line));
552 if ($tag == 'p' and !$this->hasRawText($content)) {
560 $line = $this->graf($line);
564 $line = $this->doPBr($line);
568 $out[count($out)-1] .= "\n".$line;
579 if ($ext) $out[count($out)-1] .= $c1;
585 // -------------------------------------------------------------
588 // $this->dump($m);
590 $atts = $this->pba($atts);
596 $fnid = empty($this->fn[$fns[1]]) ? $fns[1] : $this->fn[$fns[1]];
604 $cite = $this->checkRefs($cite);
616 $content = $this->shelve($this->encode_html(rtrim($content, "\n")."\n"));
619 $content = $this->shelve($content);
624 $content = $this->shelve($this->encode_html(rtrim($content, "\n")."\n"));
634 $content = $this->graf($content);
639 // -------------------------------------------------------------
643 if (!$this->lite) {
644 $text = $this->noTextile($text);
645 $text = $this->code($text);
648 $text = $this->links($text);
649 if (!$this->noimage)
650 $text = $this->image($text);
652 if (!$this->lite) {
653 $text = $this->lists($text);
654 $text = $this->table($text);
657 $text = $this->span($text);
658 $text = $this->footnoteRef($text);
659 $text = $this->glyphs($text);
663 // -------------------------------------------------------------
666 $qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~','\^');
673 ({$this->c})
684 // -------------------------------------------------------------
693 '-' => 'del',
702 $atts = $this->pba($atts);
707 // $this->dump($out);
713 // -------------------------------------------------------------
719 (' . $this->c . ') # $atts
724 ('.$this->urlch.'+) # $url
731 // -------------------------------------------------------------
736 $url = $this->checkRefs($url);
738 $atts = $this->pba($atts);
739 $atts .= ($title != '') ? ' title="' . $this->encode_html($title) . '"' : '';
741 if (!$this->noimage)
742 $text = $this->image($text);
744 $text = $this->span($text);
745 $text = $this->glyphs($text);
747 $url = $this->relURL($url);
749 …$out = '<a href="' . $this->encode_html($url . $slash) . '"' . $atts . $this->rel . '>' . $text . …
751 // $this->dump($out);
752 return $this->shelve($out);
756 // -------------------------------------------------------------
763 // -------------------------------------------------------------
767 $this->urlrefs[$flag] = $url;
771 // -------------------------------------------------------------
774 return (isset($this->urlrefs[$text])) ? $this->urlrefs[$text] : $text;
777 // -------------------------------------------------------------
784 $url = $this->hu.$url;
785 if ($this->restricted and !empty($parts['scheme']) and
786 !in_array($parts['scheme'], $this->url_schemes))
791 // -------------------------------------------------------------
798 ($this->c) # optional style,class atts
799 (?:\. )? # optional dot-space
809 // -------------------------------------------------------------
813 $atts = $this->pba($atts);
814 $atts .= ($algn != '') ? ' align="' . $this->iAlign($algn) . '"' : '';
820 $href = (isset($m[5])) ? $this->checkRefs($m[5]) : '';
821 $url = $this->checkRefs($url);
823 $url = $this->relURL($url);
834 // -------------------------------------------------------------
837 $text = $this->doSpecial($text, '<code>', '</code>', 'fCode');
838 $text = $this->doSpecial($text, '@', '@', 'fCode');
839 $text = $this->doSpecial($text, '<pre>', '</pre>', 'fPre');
843 // -------------------------------------------------------------
847 if ($this->restricted)
849 return $before.$this->shelve('<code>'.$text.'</code>').$after;
851 return $before.$this->shelve('<code>'.$this->encode_html($text).'</code>').$after;
854 // -------------------------------------------------------------
858 if ($this->restricted)
860 return $before.'<pre>'.$this->shelve($text).'</pre>'.$after;
862 return $before.'<pre>'.$this->shelve($this->encode_html($text)).'</pre>'.$after;
864 // -------------------------------------------------------------
868 $this->shelf[$i] = $val;
872 // -------------------------------------------------------------
875 if (is_array($this->shelf))
878 $text = strtr($text, $this->shelf);
884 // -------------------------------------------------------------
888 return preg_replace("/&(?![#a-z0-9]+;)/i", "x%x%", $text);
891 // -------------------------------------------------------------
896 ? $this->encode_high($text)
897 : htmlentities($text, ENT_NOQUOTES, "utf-8");
900 // -------------------------------------------------------------
904 /* de-entify any remaining angle brackets or ampersands */
909 // -------------------------------------------------------------
919 // -------------------------------------------------------------
926 // -------------------------------------------------------------
931 return $before.$this->shelve($this->encode_html($text)).$after;
934 // -------------------------------------------------------------
937 $text = $this->doSpecial($text, '<notextile>', '</notextile>', 'fTextile');
938 return $this->doSpecial($text, '==', '==', 'fTextile');
942 // -------------------------------------------------------------
947 return $before.$this->shelve($notextile).$after;
950 // -------------------------------------------------------------
953 return preg_replace('/\b\[([0-9]+)\](\s)?/Ue',
954 '$this->footnoteID(\'\1\',\'\2\')', $text);
957 // -------------------------------------------------------------
960 if (empty($this->fn[$id]))
961 $this->fn[$id] = uniqid(rand());
962 $fnid = $this->fn[$id];
966 // -------------------------------------------------------------
980 '/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/', // 3+ uppercase acronym
981 '/\b([A-Z][A-Z\'\-]+[A-Z])(?=[\s.,\)>])/', // 3+ uppercase
983 '/(\s?)--(\s?)/', // em dash
984 '/\s-(?:\s|$)/', // en dash
991 extract($this->glyph, EXTR_PREFIX_ALL, 'txt');
1011 $text = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
1021 // -------------------------------------------------------------
1031 // -------------------------------------------------------------
1042 // -------------------------------------------------------------
1047 '-' => 'middle',
1052 // -------------------------------------------------------------
1054 function encode_high($text, $charset = "UTF-8")
1056 return mb_encode_numericentity($text, $this->cmap(), $charset);
1059 // -------------------------------------------------------------
1061 function decode_high($text, $charset = "UTF-8")
1063 return mb_decode_numericentity($text, $this->cmap(), $charset);
1066 // -------------------------------------------------------------
1076 // -------------------------------------------------------------
1092 // -------------------------------------------------------------
1100 // -------------------------------------------------------------
1117 // -------------------------------------------------------------
1125 // -------------------------------------------------------------
1129 $this->btag = array('bq', 'p');
1130 return $this->block($text."\n\n");