Advertisement
Guest User

CloCkWeRX

a guest
Oct 27th, 2008
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 191.77 KB | None | 0 0
  1. Index: Text/Wiki/Parse/Cowiki/Anchor.php
  2. ===================================================================
  3. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Anchor.php,v
  4. retrieving revision 1.1
  5. diff -u -r1.1 Anchor.php
  6. --- Text/Wiki/Parse/Cowiki/Anchor.php 21 Jul 2005 20:56:13 -0000 1.1
  7. +++ Text/Wiki/Parse/Cowiki/Anchor.php 28 Oct 2008 02:23:51 -0000
  8. @@ -1,85 +1,73 @@
  9. <?php
  10. -
  11. /**
  12. -*
  13. -* Parses for anchor targets.
  14. -*
  15. -* @category Text
  16. -*
  17. -* @package Text_Wiki
  18. -*
  19. -* @author Manuel Holtgrewe <purestorm at ggnore dot net>
  20. -*
  21. -* @author Paul M. Jones <pmjones@php.net>
  22. -*
  23. -* @license LGPL
  24. -*
  25. -* @version $Id: Anchor.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  26. -*
  27. -*/
  28. + * Parses for anchor targets.
  29. + *
  30. + * PHP version 4
  31. + *
  32. + * @category Text
  33. + * @package Text_Wiki
  34. + * @author Manuel Holtgrewe <purestorm@ggnore.net>
  35. + * @author Paul M. Jones <pmjones@php.net>
  36. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  37. + * @version CVS: $Id: Anchor.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  38. + * @link http://pear.php.net/package/Text_Wiki
  39. + */
  40.  
  41. /**
  42. -*
  43. -* This class implements a Text_Wiki_Parse to add an anchor target name
  44. -* in the wiki page.
  45. -*
  46. -* @author Manuel Holtgrewe <purestorm at ggnore dot net>
  47. -*
  48. -* @author Paul M. Jones <pmjones at ciaweb dot net>
  49. -*
  50. -* @category Text
  51. -*
  52. -* @package Text_Wiki
  53. -*
  54. -*/
  55. -
  56. -//Not used in CoWiki
  57. -class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse {
  58. + * This class implements a Text_Wiki_Parse to add an anchor target name
  59. + * in the wiki page.
  60. + *
  61. + * Not used in Cowiki
  62. + *
  63. + * @category Text
  64. + * @package Text_Wiki
  65. + * @author Paul M. Jones <pmjones@php.net>
  66. + * @author Manuel Holtgrewe <purestorm@ggnore.net>
  67. + * @copyright 2005 Paul M. Jones
  68. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  69. + * @version Release: @package_version@
  70. + * @link http://pear.php.net/package/Text_Wiki
  71. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  72. + */
  73. +class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse
  74. +{
  75.  
  76.  
  77. /**
  78. - *
  79. - * The regular expression used to find source text matching this
  80. - * rule. Looks like a macro: [[# anchor_name]]
  81. - *
  82. - * @access public
  83. - *
  84. - * @var string
  85. - *
  86. - */
  87. -
  88. + * The regular expression used to find source text matching this
  89. + * rule. Looks like a macro: [[# anchor_name]]
  90. + *
  91. + * @access public
  92. + *
  93. + * @var string
  94. + *
  95. + * @see parse()
  96. + */
  97. var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i';
  98.  
  99.  
  100. /**
  101. - *
  102. - * Generates a token entry for the matched text. Token options are:
  103. - *
  104. - * 'text' => The full matched text, not including the <code></code> tags.
  105. - *
  106. - * @access public
  107. - *
  108. - * @param array &$matches The array of matches from parse().
  109. - *
  110. - * @return A delimited token number to be used as a placeholder in
  111. - * the source text.
  112. - *
  113. - */
  114. -
  115. - function process(&$matches) {
  116. + * Generates a token entry for the matched text. Token options are:
  117. + *
  118. + * 'text' => The full matched text, not including the <code></code> tags.
  119. + *
  120. + * @param array &$matches The array of matches from parse().
  121. + *
  122. + * @access public
  123. + * @return A delimited token number to be used as a placeholder in
  124. + * the source text.
  125. + */
  126. + function process(&$matches)
  127. + {
  128.  
  129. $name = $matches[2];
  130. $text = $matches[3];
  131.  
  132. - $start = $this->wiki->addToken(
  133. - $this->rule,
  134. - array('type' => 'start', 'name' => $name)
  135. - );
  136. + $start = $this->wiki->addToken($this->rule,
  137. + array('type' => 'start', 'name' => $name));
  138.  
  139. - $end = $this->wiki->addToken(
  140. - $this->rule,
  141. - array('type' => 'end', 'name' => $name)
  142. - );
  143. + $end = $this->wiki->addToken($this->rule,
  144. + array('type' => 'end', 'name' => $name));
  145.  
  146. // done, place the script output directly in the source
  147. return $start . trim($text) . $end;
  148. Index: Text/Wiki/Parse/Cowiki/Blockquote.php
  149. ===================================================================
  150. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Blockquote.php,v
  151. retrieving revision 1.1
  152. diff -u -r1.1 Blockquote.php
  153. --- Text/Wiki/Parse/Cowiki/Blockquote.php 21 Jul 2005 20:56:13 -0000 1.1
  154. +++ Text/Wiki/Parse/Cowiki/Blockquote.php 28 Oct 2008 02:23:51 -0000
  155. @@ -1,180 +1,157 @@
  156. <?php
  157. -
  158. /**
  159. -*
  160. -* Parse for block-quoted text.
  161. -*
  162. -* @category Text
  163. -*
  164. -* @package Text_Wiki
  165. -*
  166. -* @author Paul M. Jones <pmjones@php.net>
  167. -*
  168. -* @license LGPL
  169. -*
  170. -* @version $Id: Blockquote.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  171. -*
  172. -*/
  173. + * Parse for block-quoted text.
  174. + *
  175. + * PHP version 4, 5
  176. + *
  177. + * @category Text
  178. + * @package Text_Wiki
  179. + * @author Paul M. Jones <pmjones@php.net>
  180. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  181. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  182. + * @link http://pear.php.net/package/Text_Wiki
  183. + */
  184.  
  185. /**
  186. -*
  187. -* Parse for block-quoted text.
  188. -*
  189. -* Find source text marked as a blockquote, identified by any number of
  190. -* greater-than signs '>' at the start of the line, followed by a space,
  191. -* and then the quote text; each '>' indicates an additional level of
  192. -* quoting.
  193. -*
  194. -* @category Text
  195. -*
  196. -* @package Text_Wiki
  197. -*
  198. -* @author Paul M. Jones <pmjones@php.net>
  199. -*
  200. -*/
  201. -
  202. -//Not really used in CoWiki...sort of like <posting>
  203. -class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse {
  204. -
  205. -
  206. + * Parse for block-quoted text.
  207. + *
  208. + * Not really used in CoWiki...sort of like <posting>
  209. + *
  210. + * Find source text marked as a blockquote, identified by any number of
  211. + * greater-than signs '>' at the start of the line, followed by a space,
  212. + * and then the quote text; each '>' indicates an additional level of
  213. + * quoting.
  214. + *
  215. + * @category Text
  216. + * @package Text_Wiki
  217. + * @author Paul M. Jones <pmjones@php.net>
  218. + * @copyright 2005 Paul M. Jones
  219. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  220. + * @version Release: @package_version@
  221. + * @link http://pear.php.net/package/Text_Wiki
  222. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  223. + */
  224. +class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse
  225. +{
  226. +
  227. /**
  228. - *
  229. - * Regex for parsing the source text.
  230. - *
  231. - * @access public
  232. - *
  233. - * @var string
  234. - *
  235. - * @see parse()
  236. - *
  237. - */
  238. -
  239. + * The regular expression used to parse the source text and find
  240. + * matches conforming to this rule. Used by the parse() method.
  241. + *
  242. + * @access public
  243. + *
  244. + * @var string
  245. + *
  246. + * @see parse()
  247. + */
  248. var $regex = '/\n((\>).*\n)(?!(\>))/Us';
  249. -
  250. -
  251. +
  252. +
  253. /**
  254. - *
  255. - * Generates a replacement for the matched text.
  256. - *
  257. - * Token options are:
  258. - *
  259. - * 'type' =>
  260. - * 'start' : the start of a blockquote
  261. - * 'end' : the end of a blockquote
  262. - *
  263. - * 'level' => the indent level (0 for the first level, 1 for the
  264. - * second, etc)
  265. - *
  266. - * @access public
  267. - *
  268. - * @param array &$matches The array of matches from parse().
  269. - *
  270. - * @return A series of text and delimited tokens marking the different
  271. - * list text and list elements.
  272. - *
  273. - */
  274. -
  275. + * Generates a replacement for the matched text.
  276. + *
  277. + * Token options are:
  278. + *
  279. + * 'type' =>
  280. + * 'start' : the start of a blockquote
  281. + * 'end' : the end of a blockquote
  282. + *
  283. + * 'level' => the indent level (0 for the first level, 1 for the
  284. + * second, etc)
  285. + *
  286. + * @param array &$matches The array of matches from parse().
  287. + *
  288. + * @access public
  289. + * @return A series of text and delimited tokens marking the different
  290. + * list text and list elements.
  291. + */
  292. function process(&$matches)
  293. {
  294. // the replacement text we will return to parse()
  295. $return = '';
  296. -
  297. +
  298. // the list of post-processing matches
  299. $list = array();
  300. -
  301. +
  302. // $matches[1] is the text matched as a list set by parse();
  303. // create an array called $list that contains a new set of
  304. // matches for the various list-item elements.
  305. - preg_match_all(
  306. - '=^(\>+) (.*\n)=Ums',
  307. - $matches[1],
  308. - $list,
  309. - PREG_SET_ORDER
  310. - );
  311. -
  312. + preg_match_all('=^(\>+) (.*\n)=Ums',
  313. + $matches[1],
  314. + $list,
  315. + PREG_SET_ORDER);
  316. +
  317. // a stack of starts and ends; we keep this so that we know what
  318. // indent level we're at.
  319. $stack = array();
  320. -
  321. +
  322. // loop through each list-item element.
  323. foreach ($list as $key => $val) {
  324. -
  325. +
  326. // $val[0] is the full matched list-item line
  327. // $val[1] is the number of initial '>' chars (indent level)
  328. // $val[2] is the quote text
  329. -
  330. +
  331. // we number levels starting at 1, not zero
  332. $level = strlen($val[1]);
  333. -
  334. +
  335. // get the text of the line
  336. $text = $val[2];
  337. -
  338. +
  339. // add a level to the list?
  340. while ($level > count($stack)) {
  341. -
  342. +
  343. // the current indent level is greater than the number
  344. // of stack elements, so we must be starting a new
  345. - // level. push the new level onto the stack with a
  346. + // level. push the new level onto the stack with a
  347. // dummy value (boolean true)...
  348. array_push($stack, true);
  349. -
  350. +
  351. $return .= "\n";
  352. -
  353. +
  354. // ...and add a start token to the return.
  355. - $return .= $this->wiki->addToken(
  356. - $this->rule,
  357. - array(
  358. - 'type' => 'start',
  359. - 'level' => $level - 1
  360. - )
  361. - );
  362. -
  363. + $return .= $this->wiki->addToken($this->rule,
  364. + array('type' => 'start',
  365. + 'level' => $level - 1));
  366. +
  367. $return .= "\n\n";
  368. }
  369. -
  370. +
  371. // remove a level?
  372. while (count($stack) > $level) {
  373. -
  374. +
  375. // as long as the stack count is greater than the
  376. // current indent level, we need to end list types.
  377. // continue adding end-list tokens until the stack count
  378. // and the indent level are the same.
  379. array_pop($stack);
  380. -
  381. +
  382. $return .= "\n\n";
  383. -
  384. - $return .= $this->wiki->addToken(
  385. - $this->rule,
  386. - array (
  387. - 'type' => 'end',
  388. - 'level' => count($stack)
  389. - )
  390. - );
  391. -
  392. +
  393. + $return .= $this->wiki->addToken($this->rule,
  394. + array ('type' => 'end',
  395. + 'level' => count($stack)));
  396. +
  397. $return .= "\n";
  398. }
  399. -
  400. +
  401. // add the line text.
  402. $return .= $text;
  403. }
  404. -
  405. +
  406. // the last line may have been indented. go through the stack
  407. // and create end-tokens until the stack is empty.
  408. $return .= "\n";
  409. -
  410. +
  411. while (count($stack) > 0) {
  412. array_pop($stack);
  413. - $return .= $this->wiki->addToken(
  414. - $this->rule,
  415. - array (
  416. - 'type' => 'end',
  417. - 'level' => count($stack)
  418. - )
  419. - );
  420. + $return .= $this->wiki->addToken($this->rule,
  421. + array ('type' => 'end',
  422. + 'level' => count($stack)));
  423. }
  424. -
  425. +
  426. // we're done! send back the replacement text.
  427. return "\n$return\n\n";
  428. }
  429. }
  430. -?>
  431. \ No newline at end of file
  432. +?>
  433. Index: Text/Wiki/Parse/Cowiki/Bold.php
  434. ===================================================================
  435. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Bold.php,v
  436. retrieving revision 1.1
  437. diff -u -r1.1 Bold.php
  438. --- Text/Wiki/Parse/Cowiki/Bold.php 21 Jul 2005 20:56:13 -0000 1.1
  439. +++ Text/Wiki/Parse/Cowiki/Bold.php 28 Oct 2008 02:23:51 -0000
  440. @@ -1,79 +1,70 @@
  441. <?php
  442.  
  443. /**
  444. -*
  445. -* Parses for bold text.
  446. -*
  447. -* @category Text
  448. -*
  449. -* @package Text_Wiki
  450. -*
  451. -* @author Paul M. Jones <pmjones@php.net>
  452. -*
  453. -* @license LGPL
  454. -*
  455. -* @version $Id: Bold.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  456. -*
  457. -*/
  458. + * Parses for bold text.
  459. +*
  460. + * PHP version 4, 5
  461. + *
  462. + * @category Text
  463. + * @package Text_Wiki
  464. + * @author Paul M. Jones <pmjones@php.net>
  465. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  466. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  467. + * @link http://pear.php.net/package/Text_Wiki
  468. + */
  469.  
  470. /**
  471. -*
  472. -* Parses for bold text.
  473. -*
  474. -* This class implements a Text_Wiki_Rule to find source text marked for
  475. -* strong emphasis (bold) as defined by text surrounded by three
  476. -* single-quotes. On parsing, the text itself is left in place, but the
  477. -* starting and ending instances of three single-quotes are replaced with
  478. -* tokens.
  479. -*
  480. -* @category Text
  481. -*
  482. -* @package Text_Wiki
  483. -*
  484. -* @author Paul M. Jones <pmjones@php.net>
  485. -*
  486. -*/
  487. + * Parses for bold text.
  488. + *
  489. + * This class implements a Text_Wiki_Rule to find source text marked for
  490. + * strong emphasis (bold) as defined by text surrounded by three
  491. + * single-quotes. On parsing, the text itself is left in place, but the
  492. + * starting and ending instances of three single-quotes are replaced with
  493. + * tokens.
  494. + *
  495. + * @category Text
  496. + * @package Text_Wiki
  497. + * @author Paul M. Jones <pmjones@php.net>
  498. + * @copyright 2005 Paul M. Jones
  499. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  500. + * @version Release: @package_version@
  501. + * @link http://pear.php.net/package/Text_Wiki
  502. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  503. + */
  504. +class Text_Wiki_Parse_Bold extends Text_Wiki_Parse
  505. +{
  506. +
  507.  
  508. -class Text_Wiki_Parse_Bold extends Text_Wiki_Parse {
  509. -
  510. -
  511. /**
  512. - *
  513. - * The regular expression used to parse the source text and find
  514. - * matches conforming to this rule. Used by the parse() method.
  515. - *
  516. - * @access public
  517. - *
  518. - * @var string
  519. - *
  520. - * @see parse()
  521. - *
  522. - */
  523. -
  524. + * The regular expression used to parse the source text and find
  525. + * matches conforming to this rule. Used by the parse() method.
  526. + *
  527. + * @access public
  528. + *
  529. + * @var string
  530. + *
  531. + * @see parse()
  532. + */
  533. var $regex = '/\*(()|.*)\*/U';
  534. -
  535. -
  536. +
  537. +
  538. /**
  539. - *
  540. - * Generates a replacement for the matched text. Token options are:
  541. - *
  542. - * 'type' => ['start'|'end'] The starting or ending point of the
  543. - * emphasized text. The text itself is left in the source.
  544. - *
  545. - * @access public
  546. - *
  547. - * @param array &$matches The array of matches from parse().
  548. - *
  549. - * @return A pair of delimited tokens to be used as a placeholder in
  550. - * the source text surrounding the text to be emphasized.
  551. - *
  552. - */
  553. -
  554. + * Generates a replacement for the matched text. Token options are:
  555. + *
  556. + * 'type' => ['start'|'end'] The starting or ending point of the
  557. + * emphasized text. The text itself is left in the source.
  558. + *
  559. + * @param array &$matches The array of matches from parse().
  560. + *
  561. + * @access public
  562. + * @return A delimited token number to be used as a placeholder in
  563. + * the source text.
  564. + */
  565. function process(&$matches)
  566. {
  567. $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  568. - $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  569. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  570. return $start . $matches[1] . $end;
  571. }
  572. }
  573. -?>
  574. \ No newline at end of file
  575. +?>
  576. Index: Text/Wiki/Parse/Cowiki/Break.php
  577. ===================================================================
  578. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Break.php,v
  579. retrieving revision 1.1
  580. diff -u -r1.1 Break.php
  581. --- Text/Wiki/Parse/Cowiki/Break.php 21 Jul 2005 20:56:13 -0000 1.1
  582. +++ Text/Wiki/Parse/Cowiki/Break.php 28 Oct 2008 02:23:51 -0000
  583. @@ -1,73 +1,64 @@
  584. <?php
  585. -
  586. /**
  587. -*
  588. -* Parses for explicit line breaks.
  589. -*
  590. -* @category Text
  591. -*
  592. -* @package Text_Wiki
  593. -*
  594. -* @author Paul M. Jones <pmjones@php.net>
  595. -*
  596. -* @license LGPL
  597. -*
  598. -* @version $Id: Break.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  599. -*
  600. -*/
  601. + * Parses for explicit line breaks.
  602. + *
  603. + * PHP version 4, 5
  604. + *
  605. + * @category Text
  606. + * @package Text_Wiki
  607. + * @author Paul M. Jones <pmjones@php.net>
  608. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  609. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  610. + * @link http://pear.php.net/package/Text_Wiki
  611. + */
  612.  
  613. /**
  614. -*
  615. -* Parses for explicit line breaks.
  616. -*
  617. -* This class implements a Text_Wiki_Parse to mark forced line breaks in the
  618. -* source text.
  619. -*
  620. -* @category Text
  621. -*
  622. -* @package Text_Wiki
  623. -*
  624. -* @author Paul M. Jones <pmjones@php.net>
  625. -*
  626. -*/
  627. -
  628. -//Not used in CoWiki
  629. -class Text_Wiki_Parse_Break extends Text_Wiki_Parse {
  630. -
  631. -
  632. + * Parses for explicit line breaks.
  633. + *
  634. + * Not used in CoWiki
  635. + *
  636. + * This class implements a Text_Wiki_Parse to mark forced line breaks in the
  637. + * source text.
  638. + *
  639. + * @category Text
  640. + * @package Text_Wiki
  641. + * @author Paul M. Jones <pmjones@php.net>
  642. + * @copyright 2005 Paul M. Jones
  643. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  644. + * @version Release: @package_version@
  645. + * @link http://pear.php.net/package/Text_Wiki
  646. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  647. + */
  648. +class Text_Wiki_Parse_Break extends Text_Wiki_Parse
  649. +{
  650. +
  651. +
  652. /**
  653. - *
  654. - * The regular expression used to parse the source text and find
  655. - * matches conforming to this rule. Used by the parse() method.
  656. - *
  657. - * @access public
  658. - *
  659. - * @var string
  660. - *
  661. - * @see parse()
  662. - *
  663. - */
  664. -
  665. + * The regular expression used to parse the source text and find
  666. + * matches conforming to this rule. Used by the parse() method.
  667. + *
  668. + * @access public
  669. + *
  670. + * @var string
  671. + *
  672. + * @see parse()
  673. + */
  674. var $regex = '/ \\\n/';
  675. -
  676. -
  677. +
  678. +
  679. /**
  680. - *
  681. - * Generates a replacement token for the matched text.
  682. - *
  683. - * @access public
  684. - *
  685. - * @param array &$matches The array of matches from parse().
  686. - *
  687. - * @return string A delimited token to be used as a placeholder in
  688. - * the source text.
  689. - *
  690. - */
  691. -
  692. + * Generates a replacement token for the matched text.
  693. + *
  694. + * @param array &$matches The array of matches from parse().
  695. + *
  696. + * @return string A delimited token to be used as a placeholder in
  697. + * the source text.
  698. + * @access public
  699. + */
  700. function process(&$matches)
  701. - {
  702. + {
  703. return $this->wiki->addToken($this->rule);
  704. }
  705. }
  706.  
  707. -?>
  708. \ No newline at end of file
  709. +?>
  710. Index: Text/Wiki/Parse/Cowiki/Center.php
  711. ===================================================================
  712. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Center.php,v
  713. retrieving revision 1.1
  714. diff -u -r1.1 Center.php
  715. --- Text/Wiki/Parse/Cowiki/Center.php 21 Jul 2005 20:56:13 -0000 1.1
  716. +++ Text/Wiki/Parse/Cowiki/Center.php 28 Oct 2008 02:23:51 -0000
  717. @@ -1,79 +1,65 @@
  718. <?php
  719. -
  720. /**
  721. -*
  722. -* Parses for centered lines of text.
  723. -*
  724. -* @category Text
  725. -*
  726. -* @package Text_Wiki
  727. -*
  728. -* @author Paul M. Jones <pmjones@php.net>
  729. -*
  730. -* @license LGPL
  731. -*
  732. -* @version $Id: Center.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  733. -*
  734. -*/
  735. + * Parses for centered lines of text.
  736. + *
  737. + * PHP version 4, 5
  738. + *
  739. + * @category Text
  740. + * @package Text_Wiki
  741. + * @author Paul M. Jones <pmjones@php.net>
  742. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  743. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  744. + * @link http://pear.php.net/package/Text_Wiki
  745. + */
  746.  
  747. /**
  748. -*
  749. -* Parses for centered lines of text.
  750. -*
  751. -* This class implements a Text_Wiki_Parse to find lines marked for centering.
  752. -* The line must start with "= " (i.e., an equal-sign followed by a space).
  753. -*
  754. -* @category Text
  755. -*
  756. -* @package Text_Wiki
  757. -*
  758. -* @author Paul M. Jones <pmjones@php.net>
  759. -*
  760. -*/
  761. + * Parses for centered lines of text.
  762. + *
  763. + * None in CoWiki
  764. + *
  765. + * This class implements a Text_Wiki_Parse to find lines marked for centering.
  766. + * The line must start with "= " (i.e., an equal-sign followed by a space).
  767. + *
  768. + * @category Text
  769. + * @package Text_Wiki
  770. + * @author Paul M. Jones <pmjones@php.net>
  771. + * @copyright 2005 Paul M. Jones
  772. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  773. + * @version Release: @package_version@
  774. + * @link http://pear.php.net/package/Text_Wiki
  775. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  776. + */
  777. +class Text_Wiki_Parse_Center extends Text_Wiki_Parse
  778. +{
  779. +
  780.  
  781. -//None in CoWiki
  782. -class Text_Wiki_Parse_Center extends Text_Wiki_Parse {
  783. -
  784. -
  785. /**
  786. - *
  787. - * The regular expression used to find source text matching this
  788. - * rule.
  789. - *
  790. - * @access public
  791. - *
  792. - * @var string
  793. - *
  794. - */
  795. -
  796. + * The regular expression used to parse the source text and find
  797. + * matches conforming to this rule. Used by the parse() method.
  798. + *
  799. + * @access public
  800. + *
  801. + * @var string
  802. + *
  803. + * @see parse()
  804. + */
  805. var $regex = '/\n::(.*?)::\n/';
  806. -
  807. +
  808. /**
  809. - *
  810. - * Generates a token entry for the matched text.
  811. - *
  812. - * @access public
  813. - *
  814. - * @param array &$matches The array of matches from parse().
  815. - *
  816. - * @return A delimited token number to be used as a placeholder in
  817. - * the source text.
  818. - *
  819. - */
  820. -
  821. + * Generates a token entry for the matched text.
  822. + *
  823. + * @param array &$matches The array of matches from parse().
  824. + *
  825. + * @access public
  826. + * @return A delimited token number to be used as a placeholder in
  827. + * the source text.
  828. + */
  829. function process(&$matches)
  830. {
  831. - $start = $this->wiki->addToken(
  832. - $this->rule,
  833. - array('type' => 'start')
  834. - );
  835. -
  836. - $end = $this->wiki->addToken(
  837. - $this->rule,
  838. - array('type' => 'end')
  839. - );
  840. -
  841. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  842. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  843. +
  844. return "\n" . $start . $matches[1] . $end . "\n";
  845. }
  846. }
  847. -?>
  848. \ No newline at end of file
  849. +?>
  850. Index: Text/Wiki/Parse/Cowiki/Code.php
  851. ===================================================================
  852. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Code.php,v
  853. retrieving revision 1.1
  854. diff -u -r1.1 Code.php
  855. --- Text/Wiki/Parse/Cowiki/Code.php 21 Jul 2005 20:56:13 -0000 1.1
  856. +++ Text/Wiki/Parse/Cowiki/Code.php 28 Oct 2008 02:23:51 -0000
  857. @@ -1,99 +1,91 @@
  858. <?php
  859. -
  860. /**
  861. -*
  862. -* Parses for text marked as a code example block.
  863. -*
  864. -* @category Text
  865. -*
  866. -* @package Text_Wiki
  867. -*
  868. -* @author Paul M. Jones <pmjones@php.net>
  869. -*
  870. -* @license LGPL
  871. -*
  872. -* @version $Id: Code.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  873. -*
  874. -*/
  875. + * Parses for text marked as a code example block.
  876. + *
  877. + * PHP version 4, 5
  878. + *
  879. + * @category Text
  880. + * @package Text_Wiki
  881. + * @author Paul M. Jones <pmjones@php.net>
  882. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  883. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  884. + * @link http://pear.php.net/package/Text_Wiki
  885. + */
  886.  
  887. /**
  888. -*
  889. -* Parses for text marked as a code example block.
  890. -*
  891. -* This class implements a Text_Wiki_Parse to find sections marked as code
  892. -* examples. Blocks are marked as the string <code> on a line by itself,
  893. -* followed by the inline code example, and terminated with the string
  894. -* </code> on a line by itself. The code example is run through the
  895. -* native PHP highlight_string() function to colorize it, then surrounded
  896. -* with <pre>...</pre> tags when rendered as XHTML.
  897. -*
  898. -* @category Text
  899. -*
  900. -* @package Text_Wiki
  901. -*
  902. -* @author Paul M. Jones <pmjones@php.net>
  903. -*
  904. -*/
  905. -
  906. -class Text_Wiki_Parse_Code extends Text_Wiki_Parse {
  907. -
  908. -
  909. + * Parses for text marked as a code example block.
  910. + *
  911. + * This class implements a Text_Wiki_Parse to find sections marked as code
  912. + * examples. Blocks are marked as the string <code> on a line by itself,
  913. + * followed by the inline code example, and terminated with the string
  914. + * </code> on a line by itself. The code example is run through the
  915. + * native PHP highlight_string() function to colorize it, then surrounded
  916. + * with <pre>...</pre> tags when rendered as XHTML.
  917. + *
  918. + * @category Text
  919. + * @package Text_Wiki
  920. + * @author Paul M. Jones <pmjones@php.net>
  921. + * @copyright 2005 Paul M. Jones
  922. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  923. + * @version Release: @package_version@
  924. + * @link http://pear.php.net/package/Text_Wiki
  925. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  926. + */
  927. +class Text_Wiki_Parse_Code extends Text_Wiki_Parse
  928. +{
  929. +
  930. +
  931. /**
  932. - *
  933. - * The regular expression used to find source text matching this
  934. - * rule.
  935. - *
  936. - * @access public
  937. - *
  938. - * @var string
  939. - *
  940. - */
  941. -
  942. + * The regular expression used to parse the source text and find
  943. + * matches conforming to this rule. Used by the parse() method.
  944. + *
  945. + * @access public
  946. + *
  947. + * @var string
  948. + *
  949. + * @see parse()
  950. + */
  951. var $regex = '/^(<code( [^>]*)?>)\n(.+)\n(<\/code>)(\s|$)/Umsi';
  952. -
  953. -
  954. +
  955. +
  956. /**
  957. - *
  958. - * Generates a token entry for the matched text. Token options are:
  959. - *
  960. - * 'text' => The full matched text, not including the <code></code> tags.
  961. - *
  962. - * @access public
  963. - *
  964. - * @param array &$matches The array of matches from parse().
  965. - *
  966. - * @return A delimited token number to be used as a placeholder in
  967. - * the source text.
  968. - *
  969. - */
  970. -
  971. + * Generates a token entry for the matched text. Token options are:
  972. + *
  973. + * 'text' => The full matched text, not including the <code></code> tags.
  974. + *
  975. + * @param array &$matches The array of matches from parse().
  976. + *
  977. + * @access public
  978. + * @return A delimited token number to be used as a placeholder in
  979. + * the source text.
  980. + */
  981. function process(&$matches)
  982. {
  983. // are there additional attribute arguments?
  984. $args = trim($matches[2]);
  985. -
  986. +
  987. if ($args == '') {
  988. $options = array(
  989. 'text' => $matches[3],
  990. 'attr' => array('type' => '')
  991. );
  992. } else {
  993. - // get the attributes...
  994. - $attr = $this->getAttrs($args);
  995. -
  996. - // ... and make sure we have a 'type'
  997. - if (!isset($attr['type'])) {
  998. - $attr['type'] = '';
  999. - }
  1000. -
  1001. - // retain the options
  1002. + // get the attributes...
  1003. + $attr = $this->getAttrs($args);
  1004. +
  1005. + // ... and make sure we have a 'type'
  1006. + if (!isset($attr['type'])) {
  1007. + $attr['type'] = '';
  1008. + }
  1009. +
  1010. + // retain the options
  1011. $options = array(
  1012. 'text' => $matches[3],
  1013. 'attr' => $attr
  1014. );
  1015. }
  1016. -
  1017. +
  1018. return $this->wiki->addToken($this->rule, $options) . $matches[5];
  1019. }
  1020. }
  1021. -?>
  1022. \ No newline at end of file
  1023. +?>
  1024. Index: Text/Wiki/Parse/Cowiki/Colortext.php
  1025. ===================================================================
  1026. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Colortext.php,v
  1027. retrieving revision 1.1
  1028. diff -u -r1.1 Colortext.php
  1029. --- Text/Wiki/Parse/Cowiki/Colortext.php 21 Jul 2005 20:56:13 -0000 1.1
  1030. +++ Text/Wiki/Parse/Cowiki/Colortext.php 28 Oct 2008 02:23:51 -0000
  1031. @@ -1,90 +1,69 @@
  1032. <?php
  1033. -
  1034. /**
  1035. -*
  1036. -* Parses for colorized text.
  1037. -*
  1038. -* @category Text
  1039. -*
  1040. -* @package Text_Wiki
  1041. -*
  1042. -* @author Paul M. Jones <pmjones@php.net>
  1043. -*
  1044. -* @license LGPL
  1045. -*
  1046. -* @version $Id: Colortext.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1047. -*
  1048. -*/
  1049. + * Parses for colorized text.
  1050. + *
  1051. + * PHP version 4, 5
  1052. + *
  1053. + * @category Text
  1054. + * @package Text_Wiki
  1055. + * @author Paul M. Jones <pmjones@php.net>
  1056. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1057. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1058. + * @link http://pear.php.net/package/Text_Wiki
  1059. + */
  1060.  
  1061. /**
  1062. -*
  1063. -* Parses for colorized text.
  1064. -*
  1065. -* @category Text
  1066. -*
  1067. -* @package Text_Wiki
  1068. -*
  1069. -* @author Paul M. Jones <pmjones@php.net>
  1070. -*
  1071. -*/
  1072. -
  1073. -//Not used in CoWiki
  1074. -class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse {
  1075. + * Parses for colorized text.
  1076. + * Not used in CoWiki
  1077. + *
  1078. + * @category Text
  1079. + * @package Text_Wiki
  1080. + * @author Paul M. Jones <pmjones@php.net>
  1081. + * @copyright 2005 Paul M. Jones
  1082. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1083. + * @version Release: @package_version@
  1084. + * @link http://pear.php.net/package/Text_Wiki
  1085. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1086. + */
  1087. +class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse
  1088. +{
  1089.  
  1090. /**
  1091. - *
  1092. - * The regular expression used to parse the source text and find
  1093. - * matches conforming to this rule. Used by the parse() method.
  1094. - *
  1095. - * @access public
  1096. - *
  1097. - * @var string
  1098. - *
  1099. - * @see parse()
  1100. - *
  1101. - */
  1102. -
  1103. + * The regular expression used to parse the source text and find
  1104. + * matches conforming to this rule. Used by the parse() method.
  1105. + *
  1106. + * @access public
  1107. + *
  1108. + * @var string
  1109. + *
  1110. + * @see parse()
  1111. + */
  1112. var $regex = "/~~(.+?):(.+?)~~/";
  1113.  
  1114.  
  1115. /**
  1116. - *
  1117. - * Generates a replacement for the matched text. Token options are:
  1118. - *
  1119. - * 'type' => ['start'|'end'] The starting or ending point of the
  1120. - * emphasized text. The text itself is left in the source.
  1121. - *
  1122. - * 'color' => the color indicator
  1123. - *
  1124. - * @access public
  1125. - *
  1126. - * @param array &$matches The array of matches from parse().
  1127. - *
  1128. - * @return string A pair of delimited tokens to be used as a
  1129. - * placeholder in the source text surrounding the text to be
  1130. - * emphasized.
  1131. - *
  1132. - */
  1133. -
  1134. + * Generates a replacement for the matched text. Token options are:
  1135. + * 'type' => ['start'|'end'] The starting or ending point of the
  1136. + * emphasized text. The text itself is left in the source.
  1137. + * 'color' => the color indicator
  1138. + *
  1139. + * @param array &$matches The array of matches from parse().
  1140. + *
  1141. + * @access public
  1142. + * @return A delimited token number to be used as a placeholder in
  1143. + * the source text.
  1144. + */
  1145. function process(&$matches)
  1146. {
  1147. - $start = $this->wiki->addToken(
  1148. - $this->rule,
  1149. - array(
  1150. - 'type' => 'start',
  1151. - 'color' => $matches[1]
  1152. - )
  1153. - );
  1154. + $start = $this->wiki->addToken($this->rule,
  1155. + array('type' => 'start',
  1156. + 'color' => $matches[1]));
  1157.  
  1158. - $end = $this->wiki->addToken(
  1159. - $this->rule,
  1160. - array(
  1161. - 'type' => 'end',
  1162. - 'color' => $matches[1]
  1163. - )
  1164. - );
  1165. + $end = $this->wiki->addToken($this->rule,
  1166. + array('type' => 'end',
  1167. + 'color' => $matches[1]));
  1168.  
  1169. return $start . $matches[2] . $end;
  1170. }
  1171. }
  1172. -?>
  1173. \ No newline at end of file
  1174. +?>
  1175. Index: Text/Wiki/Parse/Cowiki/Deflist.php
  1176. ===================================================================
  1177. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Deflist.php,v
  1178. retrieving revision 1.1
  1179. diff -u -r1.1 Deflist.php
  1180. --- Text/Wiki/Parse/Cowiki/Deflist.php 21 Jul 2005 20:56:13 -0000 1.1
  1181. +++ Text/Wiki/Parse/Cowiki/Deflist.php 28 Oct 2008 02:23:51 -0000
  1182. @@ -1,82 +1,73 @@
  1183. <?php
  1184. -
  1185. /**
  1186. -*
  1187. -* Parses for definition lists.
  1188. -*
  1189. -* @category Text
  1190. -*
  1191. -* @package Text_Wiki
  1192. -*
  1193. -* @author Paul M. Jones <pmjones@php.net>
  1194. -*
  1195. -* @license LGPL
  1196. -*
  1197. -* @version $Id: Deflist.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1198. -*
  1199. -*/
  1200. + * Parses for definition lists.
  1201. + *
  1202. + * PHP version 4, 5
  1203. + *
  1204. + * @category Text
  1205. + * @package Text_Wiki
  1206. + * @author Paul M. Jones <pmjones@php.net>
  1207. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1208. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1209. + * @link http://pear.php.net/package/Text_Wiki
  1210. + */
  1211.  
  1212. /**
  1213. -*
  1214. -* Parses for definition lists.
  1215. -*
  1216. -* This class implements a Text_Wiki_Parse to find source text marked as a
  1217. -* definition list. In short, if a line starts with ':' then it is a
  1218. -* definition list item; another ':' on the same line indicates the end
  1219. -* of the definition term and the beginning of the definition narrative.
  1220. -* The list items must be on sequential lines (no blank lines between
  1221. -* them) -- a blank line indicates the beginning of a new list.
  1222. -*
  1223. -* @category Text
  1224. -*
  1225. -* @package Text_Wiki
  1226. -*
  1227. -* @author Paul M. Jones <pmjones@php.net>
  1228. -*
  1229. -*/
  1230. -
  1231. -//Not used in CoWiki
  1232. -class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse {
  1233. + * Parses for definition lists.
  1234. + *
  1235. + * Not used in CoWiki
  1236. + *
  1237. + * This class implements a Text_Wiki_Parse to find source text marked as a
  1238. + * definition list. In short, if a line starts with ':' then it is a
  1239. + * definition list item; another ':' on the same line indicates the end
  1240. + * of the definition term and the beginning of the definition narrative.
  1241. + * The list items must be on sequential lines (no blank lines between
  1242. + * them) -- a blank line indicates the beginning of a new list.
  1243. + *
  1244. + * @category Text
  1245. + * @package Text_Wiki
  1246. + * @author Paul M. Jones <pmjones@php.net>
  1247. + * @copyright 2005 Paul M. Jones
  1248. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1249. + * @version Release: @package_version@
  1250. + * @link http://pear.php.net/package/Text_Wiki
  1251. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1252. + */
  1253. +class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse
  1254. +{
  1255.  
  1256.  
  1257. /**
  1258. - *
  1259. - * The regular expression used to parse the source text and find
  1260. - * matches conforming to this rule. Used by the parse() method.
  1261. - *
  1262. - * @access public
  1263. - *
  1264. - * @var string
  1265. - *
  1266. - * @see parse()
  1267. - *
  1268. - */
  1269. -
  1270. + * The regular expression used to parse the source text and find
  1271. + * matches conforming to this rule. Used by the parse() method.
  1272. + *
  1273. + * @access public
  1274. + *
  1275. + * @var string
  1276. + *
  1277. + * @see parse()
  1278. + */
  1279. var $regex = '/\n((; ).*\n)(?!(; |\n))/Us';
  1280.  
  1281.  
  1282. /**
  1283. - *
  1284. - * Generates a replacement for the matched text. Token options are:
  1285. - *
  1286. - * 'type' =>
  1287. - * 'list_start' : the start of a definition list
  1288. - * 'list_end' : the end of a definition list
  1289. - * 'term_start' : the start of a definition term
  1290. - * 'term_end' : the end of a definition term
  1291. - * 'narr_start' : the start of definition narrative
  1292. - * 'narr_end' : the end of definition narrative
  1293. - * 'unknown' : unknown type of definition portion
  1294. - *
  1295. - * @access public
  1296. - *
  1297. - * @param array &$matches The array of matches from parse().
  1298. - *
  1299. - * @return A series of text and delimited tokens marking the different
  1300. - * list text and list elements.
  1301. - *
  1302. - */
  1303. -
  1304. + * Generates a replacement for the matched text. Token options are:
  1305. + *
  1306. + * 'type' =>
  1307. + * 'list_start' : the start of a definition list
  1308. + * 'list_end' : the end of a definition list
  1309. + * 'term_start' : the start of a definition term
  1310. + * 'term_end' : the end of a definition term
  1311. + * 'narr_start' : the start of definition narrative
  1312. + * 'narr_end' : the end of definition narrative
  1313. + * 'unknown' : unknown type of definition portion
  1314. + *
  1315. + * @param array &$matches The array of matches from parse().
  1316. + *
  1317. + * @access public
  1318. + * @return A series of text and delimited tokens marking the different
  1319. + * list text and list elements.
  1320. + */
  1321. function process(&$matches)
  1322. {
  1323. // the replacement text we will return to parse()
  1324. @@ -92,12 +83,10 @@
  1325. // $matches[1] is the text matched as a list set by parse();
  1326. // create an array called $list that contains a new set of
  1327. // matches for the various definition-list elements.
  1328. - preg_match_all(
  1329. - '/^(; )(.*)?( ; )(.*)?$/Ums',
  1330. - $matches[1],
  1331. - $list,
  1332. - PREG_SET_ORDER
  1333. - );
  1334. + preg_match_all('/^(; )(.*)?( ; )(.*)?$/Ums',
  1335. + $matches[1],
  1336. + $list,
  1337. + PREG_SET_ORDER);
  1338.  
  1339. // add each term and narrative
  1340. foreach ($list as $key => $val) {
  1341. @@ -120,4 +109,4 @@
  1342. return "\n" . $return . "\n\n";
  1343. }
  1344. }
  1345. -?>
  1346. \ No newline at end of file
  1347. +?>
  1348. Index: Text/Wiki/Parse/Cowiki/Delimiter.php
  1349. ===================================================================
  1350. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Delimiter.php,v
  1351. retrieving revision 1.1
  1352. diff -u -r1.1 Delimiter.php
  1353. --- Text/Wiki/Parse/Cowiki/Delimiter.php 21 Jul 2005 20:56:13 -0000 1.1
  1354. +++ Text/Wiki/Parse/Cowiki/Delimiter.php 28 Oct 2008 02:23:51 -0000
  1355. @@ -1,80 +1,67 @@
  1356. <?php
  1357. -
  1358. /**
  1359. -*
  1360. -* Parses for Text_Wiki delimiter characters already in the source text.
  1361. -*
  1362. -* @category Text
  1363. -*
  1364. -* @package Text_Wiki
  1365. -*
  1366. -* @author Paul M. Jones <pmjones@php.net>
  1367. -*
  1368. -* @license LGPL
  1369. -*
  1370. -* @version $Id: Delimiter.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1371. -*
  1372. -*/
  1373. + * Parses for Text_Wiki delimiter characters already in the source text.
  1374. + *
  1375. + * PHP version 4, 5
  1376. + *
  1377. + * @category Text
  1378. + * @package Text_Wiki
  1379. + * @author Paul M. Jones <pmjones@php.net>
  1380. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1381. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1382. + * @link http://pear.php.net/package/Text_Wiki
  1383. + */
  1384.  
  1385. /**
  1386. -*
  1387. -* Parses for Text_Wiki delimiter characters already in the source text.
  1388. -*
  1389. -* This class implements a Text_Wiki_Parse to find instances of the delimiter
  1390. -* character already embedded in the source text; it extracts them and replaces
  1391. -* them with a delimited token, then renders them as the delimiter itself
  1392. -* when the target format is XHTML.
  1393. -*
  1394. -* @category Text
  1395. -*
  1396. -* @package Text_Wiki
  1397. -*
  1398. -* @author Paul M. Jones <pmjones@php.net>
  1399. -*
  1400. -*/
  1401. + * Parses for Text_Wiki delimiter characters already in the source text.
  1402. + *
  1403. + * This class implements a Text_Wiki_Parse to find instances of the delimiter
  1404. + * character already embedded in the source text; it extracts them and replaces
  1405. + * them with a delimited token, then renders them as the delimiter itself
  1406. + * when the target format is XHTML.
  1407. + *
  1408. + * @category Text
  1409. + * @package Text_Wiki
  1410. + * @author Paul M. Jones <pmjones@php.net>
  1411. + * @copyright 2005 Paul M. Jones
  1412. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1413. + * @version Release: @package_version@
  1414. + * @link http://pear.php.net/package/Text_Wiki
  1415. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1416. + */
  1417. +
  1418. +class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse
  1419. +{
  1420.  
  1421. -class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse {
  1422. -
  1423. /**
  1424. - *
  1425. - * Constructor. Overrides the Text_Wiki_Parse constructor so that we
  1426. - * can set the $regex property dynamically (we need to include the
  1427. - * Text_Wiki $delim character.
  1428. - *
  1429. - * @param object &$obj The calling "parent" Text_Wiki object.
  1430. - *
  1431. - * @param string $name The token name to use for this rule.
  1432. - *
  1433. - */
  1434. -
  1435. - function Text_Wiki_Parse_delimiter(&$obj)
  1436. + * Constructor. Overrides the Text_Wiki_Parse constructor so that we
  1437. + * can set the $regex property dynamically (we need to include the
  1438. + * Text_Wiki $delim character.
  1439. + *
  1440. + * @param object &$obj The calling "parent" Text_Wiki object.
  1441. + */
  1442. + function Text_Wiki_Parse_Delimiter(&$obj)
  1443. {
  1444. parent::Text_Wiki_Parse($obj);
  1445. $this->regex = '/' . $this->wiki->delim . '/';
  1446. }
  1447. -
  1448. -
  1449. +
  1450. +
  1451. /**
  1452. - *
  1453. - * Generates a token entry for the matched text. Token options are:
  1454. - *
  1455. - * 'text' => The full matched text.
  1456. - *
  1457. - * @access public
  1458. - *
  1459. - * @param array &$matches The array of matches from parse().
  1460. - *
  1461. - * @return A delimited token number to be used as a placeholder in
  1462. - * the source text.
  1463. - *
  1464. - */
  1465. -
  1466. + * Generates a token entry for the matched text. Token options are:
  1467. + *
  1468. + * 'text' => The full matched text.
  1469. + *
  1470. + * @param array &$matches The array of matches from parse().
  1471. + *
  1472. + * @access public
  1473. + * @return A delimited token number to be used as a placeholder in
  1474. + * the source text.
  1475. + */
  1476. function process(&$matches)
  1477. - {
  1478. - return $this->wiki->addToken(
  1479. - $this->rule,
  1480. - array('text' => $this->wiki->delim)
  1481. - );
  1482. + {
  1483. + return $this->wiki->addToken($this->rule,
  1484. + array('text' => $this->wiki->delim));
  1485. }
  1486. }
  1487. -?>
  1488. \ No newline at end of file
  1489. +?>
  1490. Index: Text/Wiki/Parse/Cowiki/Embed.php
  1491. ===================================================================
  1492. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Embed.php,v
  1493. retrieving revision 1.1
  1494. diff -u -r1.1 Embed.php
  1495. --- Text/Wiki/Parse/Cowiki/Embed.php 21 Jul 2005 20:56:13 -0000 1.1
  1496. +++ Text/Wiki/Parse/Cowiki/Embed.php 28 Oct 2008 02:23:51 -0000
  1497. @@ -1,50 +1,50 @@
  1498. <?php
  1499. -
  1500. /**
  1501. -*
  1502. -* Embeds the results of a PHP script at render-time.
  1503. -*
  1504. -* @category Text
  1505. -*
  1506. -* @package Text_Wiki
  1507. -*
  1508. -* @author Paul M. Jones <pmjones@php.net>
  1509. -*
  1510. -* @license LGPL
  1511. -*
  1512. -* @version $Id: Embed.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1513. -*
  1514. -*/
  1515. + * Embeds the results of a PHP script at render-time.
  1516. + *
  1517. + * PHP version 4
  1518. + *
  1519. + * @category Text
  1520. + * @package Text_Wiki
  1521. + * @author Paul M. Jones <pmjones@php.net>
  1522. + * @copyright 2005 Paul M. Jones
  1523. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1524. + * @version CVS: $Id$
  1525. + * @link http://pear.php.net/package/Text_Wiki
  1526. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1527. + */
  1528.  
  1529. /**
  1530. -*
  1531. -* Embeds the results of a PHP script at render-time.
  1532. -*
  1533. -* This class implements a Text_Wiki_Parse to embed the contents of a URL
  1534. -* inside the page at render-time. Typically used to get script output.
  1535. -* This differs from the 'include' rule, which incorporates results at
  1536. -* parse-time; 'embed' output does not get parsed by Text_Wiki, while
  1537. -* 'include' ouput does.
  1538. -*
  1539. -* This rule is inherently not secure; it allows cross-site scripting to
  1540. -* occur if the embedded output has <script> or other similar tags. Be
  1541. -* careful.
  1542. -*
  1543. -* @category Text
  1544. -*
  1545. -* @package Text_Wiki
  1546. -*
  1547. -* @author Paul M. Jones <pmjones@php.net>
  1548. -*
  1549. -*/
  1550. -
  1551. -//Not used in CoWiki
  1552. -class Text_Wiki_Parse_Embed extends Text_Wiki_Parse {
  1553. -
  1554. + * Embeds the results of a PHP script at render-time.
  1555. + *
  1556. + * Not used in CoWiki
  1557. + *
  1558. + * This class implements a Text_Wiki_Parse to embed the contents of a URL
  1559. + * inside the page at render-time. Typically used to get script output.
  1560. + * This differs from the 'include' rule, which incorporates results at
  1561. + * parse-time; 'embed' output does not get parsed by Text_Wiki, while
  1562. + * 'include' ouput does.
  1563. + *
  1564. + * This rule is inherently not secure; it allows cross-site scripting to
  1565. + * occur if the embedded output has <script> or other similar tags. Be
  1566. + * careful.
  1567. + *
  1568. + * @category Text
  1569. + * @package Text_Wiki
  1570. + * @author Paul M. Jones <pmjones@php.net>
  1571. + * @copyright 2005 Paul M. Jones
  1572. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1573. + * @version Release: @package_version@
  1574. + * @link http://pear.php.net/package/Text_Wiki
  1575. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1576. + */
  1577. +class Text_Wiki_Parse_Embed extends Text_Wiki_Parse
  1578. +{
  1579. +
  1580. var $conf = array(
  1581. 'base' => '/path/to/scripts/'
  1582. );
  1583. -
  1584. +
  1585. var $file = null;
  1586.  
  1587. var $output = null;
  1588. @@ -53,55 +53,48 @@
  1589.  
  1590.  
  1591. /**
  1592. - *
  1593. - * The regular expression used to find source text matching this
  1594. - * rule.
  1595. - *
  1596. - * @access public
  1597. - *
  1598. - * @var string
  1599. - *
  1600. - */
  1601. -
  1602. + * The regular expression used to parse the source text and find
  1603. + * matches conforming to this rule. Used by the parse() method.
  1604. + *
  1605. + * @access public
  1606. + *
  1607. + * @var string
  1608. + *
  1609. + * @see parse()
  1610. + */
  1611. var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i';
  1612. -
  1613. -
  1614. +
  1615. +
  1616. /**
  1617. - *
  1618. - * Generates a token entry for the matched text. Token options are:
  1619. - *
  1620. - * 'text' => The full matched text, not including the <code></code> tags.
  1621. - *
  1622. - * @access public
  1623. - *
  1624. - * @param array &$matches The array of matches from parse().
  1625. - *
  1626. - * @return A delimited token number to be used as a placeholder in
  1627. - * the source text.
  1628. - *
  1629. - */
  1630. -
  1631. + * Generates a token entry for the matched text. Token options are:
  1632. + *
  1633. + * 'text' => The full matched text, not including the <code></code> tags.
  1634. + *
  1635. + * @param array &$matches The array of matches from parse().
  1636. + *
  1637. + * @access public
  1638. + * @return A delimited token number to be used as a placeholder in
  1639. + * the source text.
  1640. + */
  1641. function process(&$matches)
  1642. - {
  1643. + {
  1644. // save the file location
  1645. $this->file = $this->getConf('base', './') . $matches[2];
  1646. -
  1647. +
  1648. // extract attribs as variables in the local space
  1649. $this->vars = $this->getAttrs($matches[3]);
  1650. unset($this->vars['this']);
  1651. extract($this->vars);
  1652. -
  1653. +
  1654. // run the script
  1655. ob_start();
  1656. - include($this->file);
  1657. + include $this->file;
  1658. $this->output = ob_get_contents();
  1659. ob_end_clean();
  1660. -
  1661. +
  1662. // done, place the script output directly in the source
  1663. - return $this->wiki->addToken(
  1664. - $this->rule,
  1665. - array('text' => $this->output)
  1666. - );
  1667. + return $this->wiki->addToken($this->rule,
  1668. + array('text' => $this->output));
  1669. }
  1670. }
  1671. -?>
  1672. \ No newline at end of file
  1673. +?>
  1674. Index: Text/Wiki/Parse/Cowiki/Emphasis.php
  1675. ===================================================================
  1676. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Emphasis.php,v
  1677. retrieving revision 1.1
  1678. diff -u -r1.1 Emphasis.php
  1679. --- Text/Wiki/Parse/Cowiki/Emphasis.php 21 Jul 2005 20:56:13 -0000 1.1
  1680. +++ Text/Wiki/Parse/Cowiki/Emphasis.php 28 Oct 2008 02:23:51 -0000
  1681. @@ -1,81 +1,76 @@
  1682. <?php
  1683.  
  1684. /**
  1685. -*
  1686. -* Parses for emphasized text.
  1687. -*
  1688. -* @category Text
  1689. -*
  1690. -* @package Text_Wiki
  1691. -*
  1692. -* @author Paul M. Jones <pmjones@php.net>
  1693. -*
  1694. -* @license LGPL
  1695. -*
  1696. -* @version $Id: Emphasis.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1697. -*
  1698. -*/
  1699. + * Parses for emphasized text.
  1700. +*
  1701. + * PHP version 4, 5
  1702. + *
  1703. + * @category Text
  1704. + * @package Text_Wiki
  1705. + * @author Paul M. Jones <pmjones@php.net>
  1706. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1707. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1708. + * @link http://pear.php.net/package/Text_Wiki
  1709. + */
  1710.  
  1711. /**
  1712. -*
  1713. -* Parses for emphasized text.
  1714. -*
  1715. + * Parses for emphasized text.
  1716. +*
  1717. * This class implements a Text_Wiki_Parse to find source text marked for
  1718. * emphasis (italics) as defined by text surrounded by two single-quotes.
  1719. * On parsing, the text itself is left in place, but the starting and ending
  1720. * instances of two single-quotes are replaced with tokens.
  1721. *
  1722. -* @category Text
  1723. -*
  1724. -* @package Text_Wiki
  1725. -*
  1726. -* @author Paul M. Jones <pmjones@php.net>
  1727. -*
  1728. -*/
  1729. -
  1730. -class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse {
  1731. -
  1732. -
  1733. + * @category Text
  1734. + * @package Text_Wiki
  1735. + * @author Paul M. Jones <pmjones@php.net>
  1736. + * @copyright 2005 Paul M. Jones
  1737. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1738. + * @version Release: @package_version@
  1739. + * @link http://pear.php.net/package/Text_Wiki
  1740. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1741. + */
  1742. +
  1743. +class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse
  1744. +{
  1745. +
  1746. +
  1747. /**
  1748. * Setting regex in constructor instead of with var as we need $this->wiki->delim
  1749. + *
  1750. + * @param object &$obj Unknown
  1751. */
  1752. - function Text_Wiki_Parse_Emphasis(&$obj) {
  1753. + function Text_Wiki_Parse_Emphasis(&$obj)
  1754. + {
  1755. parent::Text_Wiki_Parse($obj);
  1756.  
  1757. - //using [^delim] here as CoWiki's Italic syntax is a single / and its other markup is HTML syntax with / in it
  1758. + //using [^delim] here as CoWiki's Italic syntax is a single
  1759. + // and its other markup is HTML syntax with / in it
  1760. // This rule *must* be applied after all HTML style rules
  1761. $this->regex = '!/(()|[^/][^'.$this->wiki->delim.']*)/!U';
  1762. }
  1763. -
  1764. -
  1765. +
  1766. +
  1767. /**
  1768. - *
  1769. - * Generates a replacement for the matched text. Token options are:
  1770. - *
  1771. - * 'type' => ['start'|'end'] The starting or ending point of the
  1772. - * emphasized text. The text itself is left in the source.
  1773. - *
  1774. - * @access public
  1775. - *
  1776. - * @param array &$matches The array of matches from parse().
  1777. - *
  1778. - * @return string A pair of delimited tokens to be used as a
  1779. - * placeholder in the source text surrounding the text to be
  1780. - * emphasized.
  1781. - *
  1782. - */
  1783. -
  1784. + * Generates a replacement for the matched text. Token options are:
  1785. + *
  1786. + * 'type' => ['start'|'end'] The starting or ending point of the
  1787. + * emphasized text. The text itself is left in the source.
  1788. + *
  1789. + * @param array &$matches The array of matches from parse().
  1790. + *
  1791. + * @access public
  1792. + * @return string A pair of delimited tokens to be used as a
  1793. + * placeholder in the source text surrounding the text to be
  1794. + * emphasized.
  1795. + *
  1796. + */
  1797. function process(&$matches)
  1798. {
  1799. - $start = $this->wiki->addToken(
  1800. - $this->rule, array('type' => 'start')
  1801. - );
  1802. -
  1803. - $end = $this->wiki->addToken(
  1804. - $this->rule, array('type' => 'end')
  1805. - );
  1806. -
  1807. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  1808. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  1809. +
  1810. return $start . $matches[1] . $end;
  1811. }
  1812. }
  1813. -?>
  1814. \ No newline at end of file
  1815. +?>
  1816. Index: Text/Wiki/Parse/Cowiki/Freelink.php
  1817. ===================================================================
  1818. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Freelink.php,v
  1819. retrieving revision 1.1
  1820. diff -u -r1.1 Freelink.php
  1821. --- Text/Wiki/Parse/Cowiki/Freelink.php 21 Jul 2005 20:56:13 -0000 1.1
  1822. +++ Text/Wiki/Parse/Cowiki/Freelink.php 28 Oct 2008 02:23:51 -0000
  1823. @@ -1,74 +1,70 @@
  1824. <?php
  1825.  
  1826. /**
  1827. -*
  1828. -* Parses for wiki freelink text.
  1829. -*
  1830. -* @category Text
  1831. -*
  1832. -* @package Text_Wiki
  1833. -*
  1834. -* @author Paul M. Jones <pmjones@php.net>
  1835. -*
  1836. -* @license LGPL
  1837. -*
  1838. -* @version $Id: Freelink.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1839. -*
  1840. -*/
  1841. + * Parses for wiki freelink text.
  1842. + *
  1843. + * PHP version 4, 5
  1844. + *
  1845. + * @category Text
  1846. + * @package Text_Wiki
  1847. + * @author Paul M. Jones <pmjones@php.net>
  1848. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1849. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1850. + * @link http://pear.php.net/package/Text_Wiki
  1851. + */
  1852.  
  1853. /**
  1854. -*
  1855. -* Parses for freelinked page links.
  1856. -*
  1857. -* This class implements a Text_Wiki_Parse to find source text marked as a
  1858. -* wiki freelink, and automatically create a link to that page.
  1859. -*
  1860. -* A freelink is any page name not conforming to the standard
  1861. -* StudlyCapsStyle for a wiki page name. For example, a page normally
  1862. -* named MyHomePage can be renamed and referred to as ((My Home Page)) --
  1863. -* note the spaces in the page name. You can also make a "nice-looking"
  1864. -* link without renaming the target page; e.g., ((MyHomePage|My Home
  1865. -* Page)). Finally, you can use named anchors on the target page:
  1866. -* ((MyHomePage|My Home Page#Section1)).
  1867. -*
  1868. -* @category Text
  1869. -*
  1870. -* @package Text_Wiki
  1871. -*
  1872. -* @author Paul M. Jones <pmjones@php.net>
  1873. -*
  1874. -*/
  1875. -
  1876. -//Taken care of in WikiLink (I think)
  1877. -class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse {
  1878. -
  1879. + * Parses for freelinked page links.
  1880. + *
  1881. + * Taken care of in WikiLink (I think)
  1882. + * This class implements a Text_Wiki_Parse to find source text marked as a
  1883. + * wiki freelink, and automatically create a link to that page.
  1884. + *
  1885. + * A freelink is any page name not conforming to the standard
  1886. + * StudlyCapsStyle for a wiki page name. For example, a page normally
  1887. + * named MyHomePage can be renamed and referred to as ((My Home Page)) --
  1888. + * note the spaces in the page name. You can also make a "nice-looking"
  1889. + * link without renaming the target page; e.g., ((MyHomePage|My Home
  1890. + * Page)). Finally, you can use named anchors on the target page:
  1891. + * ((MyHomePage|My Home Page#Section1)).
  1892. + *
  1893. + * @category Text
  1894. + * @package Text_Wiki
  1895. + * @author Paul M. Jones <pmjones@php.net>
  1896. + * @copyright 2005 Paul M. Jones
  1897. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1898. + * @version Release: @package_version@
  1899. + * @link http://pear.php.net/package/Text_Wiki
  1900. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  1901. + */
  1902. +class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse
  1903. +{
  1904. +
  1905.  
  1906. var $regex = '/abcdefghijklmnop\(\)\(\#\*%$%/';
  1907. -
  1908. -
  1909. +
  1910. +
  1911. /**
  1912. - *
  1913. - * Generates a replacement for the matched text. Token options are:
  1914. - *
  1915. - * 'page' => the wiki page name (e.g., HomePage).
  1916. - *
  1917. - * 'text' => alternative text to be displayed in place of the wiki
  1918. - * page name.
  1919. - *
  1920. - * 'anchor' => a named anchor on the target wiki page
  1921. - *
  1922. - * @access public
  1923. - *
  1924. - * @param array &$matches The array of matches from parse().
  1925. - *
  1926. - * @return A delimited token to be used as a placeholder in
  1927. - * the source text, plus any text priot to the match.
  1928. - *
  1929. - */
  1930. -
  1931. + * Generates a replacement for the matched text. Token options are:
  1932. + *
  1933. + * 'page' => the wiki page name (e.g., HomePage).
  1934. + *
  1935. + * 'text' => alternative text to be displayed in place of the wiki
  1936. + * page name.
  1937. + *
  1938. + * 'anchor' => a named anchor on the target wiki page
  1939. + *
  1940. + * @param array &$matches The array of matches from parse().
  1941. + *
  1942. + * @access public
  1943. + * @return A delimited token to be used as a placeholder in
  1944. + * the source text, plus any text priot to the match.
  1945. + *
  1946. + */
  1947. +
  1948. function process(&$matches)
  1949. {
  1950. return;
  1951. }
  1952. }
  1953. -?>
  1954. \ No newline at end of file
  1955. +?>
  1956. Index: Text/Wiki/Parse/Cowiki/Function.php
  1957. ===================================================================
  1958. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Function.php,v
  1959. retrieving revision 1.1
  1960. diff -u -r1.1 Function.php
  1961. --- Text/Wiki/Parse/Cowiki/Function.php 21 Jul 2005 20:56:13 -0000 1.1
  1962. +++ Text/Wiki/Parse/Cowiki/Function.php 28 Oct 2008 02:23:51 -0000
  1963. @@ -1,38 +1,44 @@
  1964. <?php
  1965. -
  1966. /**
  1967. -*
  1968. -* Parses for an API function documentation block.
  1969. -*
  1970. -* @category Text
  1971. -*
  1972. -* @package Text_Wiki
  1973. -*
  1974. -* @author Paul M. Jones <pmjones@php.net>
  1975. -*
  1976. -* @license LGPL
  1977. -*
  1978. -* @version $Id: Function.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1979. -*
  1980. -*/
  1981. + * Parses for an API function documentation block.
  1982. + *
  1983. + * PHP version 4, 5
  1984. + *
  1985. + * @category Text
  1986. + * @package Text_Wiki
  1987. + * @author Paul M. Jones <pmjones@php.net>
  1988. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  1989. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  1990. + * @link http://pear.php.net/package/Text_Wiki
  1991. + */
  1992.  
  1993. /**
  1994. -*
  1995. -* Parses for an API function documentation block.
  1996. -*
  1997. -* @category Text
  1998. -*
  1999. -* @package Text_Wiki
  2000. -*
  2001. -* @author Paul M. Jones <pmjones@php.net>
  2002. -*
  2003. -*/
  2004. -
  2005. -//Not used in CoWIki
  2006. -class Text_Wiki_Parse_Function extends Text_Wiki_Parse {
  2007. + * Parses for an API function documentation block.
  2008. + *
  2009. + * @category Text
  2010. + * @package Text_Wiki
  2011. + * @author Paul M. Jones <pmjones@php.net>
  2012. + * @copyright 2005 Paul M. Jones
  2013. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2014. + * @version Release: @package_version@
  2015. + * @link http://pear.php.net/package/Text_Wiki
  2016. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2017. + */
  2018. +class Text_Wiki_Parse_Function extends Text_Wiki_Parse
  2019. +{
  2020.  
  2021. + /**
  2022. + * The regular expression used to parse the source text and find
  2023. + * matches conforming to this rule. Used by the parse() method.
  2024. + *
  2025. + * @access public
  2026. + *
  2027. + * @var string
  2028. + *
  2029. + * @see parse()
  2030. + */
  2031. var $regex = '/^(\<function\>)\n(.+)\n(\<\/function\>)(\s|$)/Umsi';
  2032. -
  2033. +
  2034. function process(&$matches)
  2035. {
  2036. // default options
  2037. @@ -43,46 +49,47 @@
  2038. 'params' => array(),
  2039. 'throws' => array()
  2040. );
  2041. -
  2042. +
  2043. // split apart the markup lines and loop through them
  2044. $lines = explode("\n", $matches[2]);
  2045. foreach ($lines as $line) {
  2046. -
  2047. +
  2048. // skip blank lines
  2049. if (trim($line) == '') {
  2050. continue;
  2051. }
  2052. -
  2053. - // find the first ':' on the line; the left part is the
  2054. +
  2055. + // find the first ':' on the line; the left part is the
  2056. // type, the right part is the value. skip lines without
  2057. // a ':' on them.
  2058. $pos = strpos($line, ':');
  2059. if ($pos === false) {
  2060. continue;
  2061. }
  2062. -
  2063. +
  2064. // $type is the line type: name, access, return, param, throws
  2065. // 012345678901234
  2066. // name: something
  2067. $type = trim(substr($line, 0, $pos));
  2068. - $val = trim(substr($line, $pos+1));
  2069. -
  2070. - switch($type) {
  2071. -
  2072. + $val = trim(substr($line, $pos+1));
  2073. +
  2074. + switch ($type) {
  2075. +
  2076. case 'a':
  2077. case 'access':
  2078. $opts['access'] = $val;
  2079. break;
  2080. -
  2081. +
  2082. case 'n':
  2083. case 'name':
  2084. $opts['name'] = $val;
  2085. break;
  2086. -
  2087. +
  2088. case 'p':
  2089. case 'param':
  2090. $tmp = explode(',', $val);
  2091. - $k = count($tmp);
  2092. + $k = count($tmp);
  2093. +
  2094. if ($k == 1) {
  2095. $opts['params'][] = array(
  2096. 'type' => $tmp[0],
  2097. @@ -103,17 +110,17 @@
  2098. );
  2099. }
  2100. break;
  2101. -
  2102. +
  2103. case 'r':
  2104. case 'return':
  2105. case 'returns':
  2106. $opts['return'] = $val;
  2107. break;
  2108. -
  2109. +
  2110. case 't':
  2111. case 'throws':
  2112. $tmp = explode(',', $val);
  2113. - $k = count($tmp);
  2114. + $k = count($tmp);
  2115. if ($k == 1) {
  2116. $opts['throws'][] = array(
  2117. 'type' => $tmp[0],
  2118. @@ -126,17 +133,17 @@
  2119. );
  2120. }
  2121. break;
  2122. -
  2123. +
  2124. default:
  2125. $opts[$type] = $val;
  2126. break;
  2127. -
  2128. +
  2129. }
  2130. }
  2131. -
  2132. +
  2133. // add the token back in place
  2134. return $this->wiki->addToken($this->rule, $opts) . $matches[4];
  2135. }
  2136. }
  2137.  
  2138. -?>
  2139. \ No newline at end of file
  2140. +?>
  2141. Index: Text/Wiki/Parse/Cowiki/Heading.php
  2142. ===================================================================
  2143. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Heading.php,v
  2144. retrieving revision 1.1
  2145. diff -u -r1.1 Heading.php
  2146. --- Text/Wiki/Parse/Cowiki/Heading.php 21 Jul 2005 20:56:13 -0000 1.1
  2147. +++ Text/Wiki/Parse/Cowiki/Heading.php 28 Oct 2008 02:23:51 -0000
  2148. @@ -1,77 +1,71 @@
  2149. <?php
  2150.  
  2151. /**
  2152. -*
  2153. -* Parses for heading text.
  2154. -*
  2155. -* @category Text
  2156. -*
  2157. -* @package Text_Wiki
  2158. -*
  2159. -* @author Paul M. Jones <pmjones@php.net>
  2160. -*
  2161. -* @license LGPL
  2162. -*
  2163. -* @version $Id: Heading.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2164. -*
  2165. -*/
  2166. + * Parses for heading text.
  2167. +*
  2168. + * PHP version 4, 5
  2169. + *
  2170. + * @category Text
  2171. + * @package Text_Wiki
  2172. + * @author Paul M. Jones <pmjones@php.net>
  2173. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2174. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2175. + * @link http://pear.php.net/package/Text_Wiki
  2176. + */
  2177.  
  2178. /**
  2179. -*
  2180. -* Parses for heading text.
  2181. -*
  2182. + * Parses for heading text.
  2183. +*
  2184. * This class implements a Text_Wiki_Parse to find source text marked to
  2185. * be a heading element, as defined by text on a line by itself prefixed
  2186. * with a number of plus signs (+). The heading text itself is left in
  2187. * the source, but is prefixed and suffixed with delimited tokens marking
  2188. * the start and end of the heading.
  2189. *
  2190. -* @category Text
  2191. -*
  2192. -* @package Text_Wiki
  2193. -*
  2194. -* @author Paul M. Jones <pmjones@php.net>
  2195. -*
  2196. -*/
  2197. -
  2198. -class Text_Wiki_Parse_Heading extends Text_Wiki_Parse {
  2199. -
  2200. -
  2201. + * @category Text
  2202. + * @package Text_Wiki
  2203. + * @author Paul M. Jones <pmjones@php.net>
  2204. + * @copyright 2005 Paul M. Jones
  2205. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2206. + * @version Release: @package_version@
  2207. + * @link http://pear.php.net/package/Text_Wiki
  2208. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2209. + */
  2210. +
  2211. +class Text_Wiki_Parse_Heading extends Text_Wiki_Parse
  2212. +{
  2213. +
  2214. +
  2215. /**
  2216. - *
  2217. - * The regular expression used to parse the source text and find
  2218. - * matches conforming to this rule. Used by the parse() method.
  2219. - *
  2220. - * @access public
  2221. - *
  2222. - * @var string
  2223. - *
  2224. - * @see parse()
  2225. - *
  2226. - */
  2227. -
  2228. + * The regular expression used to parse the source text and find
  2229. + * matches conforming to this rule. Used by the parse() method.
  2230. + *
  2231. + * @access public
  2232. + *
  2233. + * @var string
  2234. + *
  2235. + * @see parse()
  2236. + */
  2237. var $regex = '/^(\++) (.*)/m';
  2238. -
  2239. +
  2240. var $conf = array(
  2241. 'id_prefix' => 'toc'
  2242. );
  2243. -
  2244. +
  2245. /**
  2246. - *
  2247. - * Generates a replacement for the matched text. Token options are:
  2248. - *
  2249. - * 'type' => ['start'|'end'] The starting or ending point of the
  2250. - * heading text. The text itself is left in the source.
  2251. - *
  2252. - * @access public
  2253. - *
  2254. - * @param array &$matches The array of matches from parse().
  2255. - *
  2256. - * @return string A pair of delimited tokens to be used as a
  2257. - * placeholder in the source text surrounding the heading text.
  2258. - *
  2259. - */
  2260. -
  2261. + * Generates a replacement for the matched text. Token options are:
  2262. + *
  2263. + * 'type' => ['start'|'end'] The starting or ending point of the
  2264. + * heading text. The text itself is left in the source.
  2265. + *
  2266. + * @param array &$matches The array of matches from parse().
  2267. + *
  2268. + * @access public
  2269. + * @return string A pair of delimited tokens to be used as a
  2270. + * placeholder in the source text surrounding the heading text.
  2271. + *
  2272. + */
  2273. +
  2274. function process(&$matches)
  2275. {
  2276. // keep a running count for header IDs. we use this later
  2277. @@ -80,28 +74,24 @@
  2278. if (! isset($id)) {
  2279. $id = 0;
  2280. }
  2281. -
  2282. +
  2283. $prefix = htmlspecialchars($this->getConf('id_prefix'));
  2284. -
  2285. - $start = $this->wiki->addToken(
  2286. - $this->rule,
  2287. - array(
  2288. - 'type' => 'start',
  2289. - 'level' => strlen($matches[1]),
  2290. - 'text' => $matches[2],
  2291. - 'id' => $prefix . $id ++
  2292. - )
  2293. - );
  2294. -
  2295. - $end = $this->wiki->addToken(
  2296. - $this->rule,
  2297. - array(
  2298. - 'type' => 'end',
  2299. - 'level' => strlen($matches[1])
  2300. - )
  2301. - );
  2302. -
  2303. +
  2304. + $start = $this->wiki->addToken($this->rule,
  2305. + array(
  2306. + 'type' => 'start',
  2307. + 'level' => strlen($matches[1]),
  2308. + 'text' => $matches[2],
  2309. + 'id' => $prefix . $id ++
  2310. + ));
  2311. +
  2312. + $end = $this->wiki->addToken($this->rule,
  2313. + array(
  2314. + 'type' => 'end',
  2315. + 'level' => strlen($matches[1])
  2316. + ));
  2317. +
  2318. return $start . $matches[2] . $end . "\n";
  2319. }
  2320. }
  2321. -?>
  2322. \ No newline at end of file
  2323. +?>
  2324. Index: Text/Wiki/Parse/Cowiki/Horiz.php
  2325. ===================================================================
  2326. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Horiz.php,v
  2327. retrieving revision 1.1
  2328. diff -u -r1.1 Horiz.php
  2329. --- Text/Wiki/Parse/Cowiki/Horiz.php 21 Jul 2005 20:56:13 -0000 1.1
  2330. +++ Text/Wiki/Parse/Cowiki/Horiz.php 28 Oct 2008 02:23:52 -0000
  2331. @@ -1,70 +1,64 @@
  2332. <?php
  2333.  
  2334. /**
  2335. -*
  2336. -* Parses for horizontal ruling lines.
  2337. -*
  2338. -* @category Text
  2339. -*
  2340. -* @package Text_Wiki
  2341. -*
  2342. -* @author Paul M. Jones <pmjones@php.net>
  2343. -*
  2344. -* @license LGPL
  2345. -*
  2346. -* @version $Id: Horiz.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2347. -*
  2348. -*/
  2349. + * Parses for horizontal ruling lines.
  2350. +*
  2351. + * PHP version 4, 5
  2352. + *
  2353. + * @category Text
  2354. + * @package Text_Wiki
  2355. + * @author Paul M. Jones <pmjones@php.net>
  2356. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2357. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2358. + * @link http://pear.php.net/package/Text_Wiki
  2359. + */
  2360.  
  2361. /**
  2362. -*
  2363. -* Parses for horizontal ruling lines.
  2364. -*
  2365. + * Parses for horizontal ruling lines.
  2366. +*
  2367. * This class implements a Text_Wiki_Parse to find source text marked to
  2368. * be a horizontal rule, as defined by four dashed on their own line.
  2369. *
  2370. -* @category Text
  2371. -*
  2372. -* @package Text_Wiki
  2373. -*
  2374. -* @author Paul M. Jones <pmjones@php.net>
  2375. -*
  2376. -*/
  2377. -
  2378. -class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse {
  2379. -
  2380. -
  2381. + * @category Text
  2382. + * @package Text_Wiki
  2383. + * @author Paul M. Jones <pmjones@php.net>
  2384. + * @copyright 2005 Paul M. Jones
  2385. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2386. + * @version Release: @package_version@
  2387. + * @link http://pear.php.net/package/Text_Wiki
  2388. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2389. + */
  2390. +
  2391. +class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse
  2392. +{
  2393. +
  2394. +
  2395. /**
  2396. - *
  2397. - * The regular expression used to parse the source text and find
  2398. - * matches conforming to this rule. Used by the parse() method.
  2399. - *
  2400. - * @access public
  2401. - *
  2402. - * @var string
  2403. - *
  2404. - * @see parse()
  2405. - *
  2406. - */
  2407. -
  2408. + * The regular expression used to parse the source text and find
  2409. + * matches conforming to this rule. Used by the parse() method.
  2410. + *
  2411. + * @access public
  2412. + *
  2413. + * @var string
  2414. + *
  2415. + * @see parse()
  2416. + */
  2417. var $regex = '/^([-]{3,})$/m';
  2418. -
  2419. -
  2420. +
  2421. +
  2422. /**
  2423. - *
  2424. - * Generates a replacement token for the matched text.
  2425. - *
  2426. - * @access public
  2427. - *
  2428. - * @param array &$matches The array of matches from parse().
  2429. - *
  2430. - * @return string A token marking the horizontal rule.
  2431. - *
  2432. - */
  2433. -
  2434. + * Generates a replacement token for the matched text.
  2435. + *
  2436. + * @param array &$matches The array of matches from parse().
  2437. + *
  2438. + * @access public
  2439. + * @return string A token marking the horizontal rule.
  2440. + *
  2441. + */
  2442. +
  2443. function process(&$matches)
  2444. - {
  2445. + {
  2446. return $this->wiki->addToken($this->rule);
  2447. }
  2448. }
  2449. -?>
  2450. \ No newline at end of file
  2451. +?>
  2452. Index: Text/Wiki/Parse/Cowiki/Html.php
  2453. ===================================================================
  2454. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Html.php,v
  2455. retrieving revision 1.1
  2456. diff -u -r1.1 Html.php
  2457. --- Text/Wiki/Parse/Cowiki/Html.php 21 Jul 2005 20:56:13 -0000 1.1
  2458. +++ Text/Wiki/Parse/Cowiki/Html.php 28 Oct 2008 02:23:52 -0000
  2459. @@ -1,76 +1,70 @@
  2460. <?php
  2461.  
  2462. /**
  2463. -*
  2464. -* Parses for blocks of HTML code.
  2465. -*
  2466. -* @category Text
  2467. -*
  2468. -* @package Text_Wiki
  2469. -*
  2470. -* @author Paul M. Jones <pmjones@php.net>
  2471. -*
  2472. -* @license LGPL
  2473. -*
  2474. -* @version $Id: Html.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2475. -*
  2476. -*/
  2477. + * Parses for blocks of HTML code.
  2478. +*
  2479. + * PHP version 4, 5
  2480. + *
  2481. + * @category Text
  2482. + * @package Text_Wiki
  2483. + * @author Paul M. Jones <pmjones@php.net>
  2484. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2485. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2486. + * @link http://pear.php.net/package/Text_Wiki
  2487. + */
  2488.  
  2489. /**
  2490. -*
  2491. -* Parses for blocks of HTML code.
  2492. -*
  2493. -* This class implements a Text_Wiki_Parse to find source text marked as
  2494. -* HTML to be redndred as-is. The block start is marked by <html> on its
  2495. -* own line, and the block end is marked by </html> on its own line.
  2496. -*
  2497. -* @category Text
  2498. -*
  2499. -* @package Text_Wiki
  2500. -*
  2501. -* @author Paul M. Jones <pmjones@php.net>
  2502. -*
  2503. -*/
  2504. -
  2505. -//Not used in CoWiki
  2506. -class Text_Wiki_Parse_Html extends Text_Wiki_Parse {
  2507. -
  2508. -
  2509. + * Parses for blocks of HTML code.
  2510. + *
  2511. + * This class implements a Text_Wiki_Parse to find source text marked as
  2512. + * HTML to be redndred as-is. The block start is marked by <html> on its
  2513. + * own line, and the block end is marked by </html> on its own line.
  2514. + *
  2515. + * Not used in CoWiki
  2516. + *
  2517. + * @category Text
  2518. + * @package Text_Wiki
  2519. + * @author Paul M. Jones <pmjones@php.net>
  2520. + * @copyright 2005 Paul M. Jones
  2521. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2522. + * @version Release: @package_version@
  2523. + * @link http://pear.php.net/package/Text_Wiki
  2524. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2525. + */
  2526. +class Text_Wiki_Parse_Html extends Text_Wiki_Parse
  2527. +{
  2528. +
  2529. +
  2530. /**
  2531. - *
  2532. - * The regular expression used to parse the source text and find
  2533. - * matches conforming to this rule. Used by the parse() method.
  2534. - *
  2535. - * @access public
  2536. - *
  2537. - * @var string
  2538. - *
  2539. - * @see parse()
  2540. - *
  2541. - */
  2542. -
  2543. + * The regular expression used to parse the source text and find
  2544. + * matches conforming to this rule. Used by the parse() method.
  2545. + *
  2546. + * @access public
  2547. + *
  2548. + * @var string
  2549. + *
  2550. + * @see parse()
  2551. + */
  2552. var $regex = '/^\<html\>\n(.+)\n\<\/html\>(\s|$)/Umsi';
  2553. -
  2554. -
  2555. +
  2556. +
  2557. /**
  2558. - *
  2559. - * Generates a replacement for the matched text. Token options are:
  2560. - *
  2561. - * 'text' => The text of the HTML to be rendered as-is.
  2562. - *
  2563. - * @access public
  2564. - *
  2565. - * @param array &$matches The array of matches from parse().
  2566. - *
  2567. - * @return A delimited token to be used as a placeholder in
  2568. - * the source text, plus any text following the HTML block.
  2569. - *
  2570. - */
  2571. -
  2572. + * Generates a replacement for the matched text. Token options are:
  2573. + *
  2574. + * 'text' => The text of the HTML to be rendered as-is.
  2575. + *
  2576. + * @param array &$matches The array of matches from parse().
  2577. + *
  2578. + * @access public
  2579. + * @return A delimited token to be used as a placeholder in
  2580. + * the source text, plus any text following the HTML block.
  2581. + *
  2582. + */
  2583. +
  2584. function process(&$matches)
  2585. - {
  2586. + {
  2587. $options = array('text' => $matches[1]);
  2588. return $this->wiki->addToken($this->rule, $options) . $matches[2];
  2589. }
  2590. }
  2591. -?>
  2592. \ No newline at end of file
  2593. +?>
  2594. Index: Text/Wiki/Parse/Cowiki/Image.php
  2595. ===================================================================
  2596. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Image.php,v
  2597. retrieving revision 1.1
  2598. diff -u -r1.1 Image.php
  2599. --- Text/Wiki/Parse/Cowiki/Image.php 21 Jul 2005 20:56:13 -0000 1.1
  2600. +++ Text/Wiki/Parse/Cowiki/Image.php 28 Oct 2008 02:23:52 -0000
  2601. @@ -1,72 +1,66 @@
  2602. <?php
  2603. -
  2604. /**
  2605. -*
  2606. -* Parses for image placement.
  2607. -*
  2608. -* @category Text
  2609. -*
  2610. -* @package Text_Wiki
  2611. -*
  2612. -* @author Paul M. Jones <pmjones@php.net>
  2613. -*
  2614. -* @license LGPL
  2615. -*
  2616. -* @version $Id: Image.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2617. -*
  2618. -*/
  2619. + * Parses for image placement.
  2620. + *
  2621. + * PHP version 4, 5
  2622. + *
  2623. + * @category Text
  2624. + * @package Text_Wiki
  2625. + * @author Paul M. Jones <pmjones@php.net>
  2626. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2627. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2628. + * @link http://pear.php.net/package/Text_Wiki
  2629. + */
  2630.  
  2631. /**
  2632. -*
  2633. -* Parses for image placement.
  2634. -*
  2635. -* @category Text
  2636. -*
  2637. -* @package Text_Wiki
  2638. -*
  2639. -* @author Paul M. Jones <pmjones@php.net>
  2640. -*
  2641. -*/
  2642. -
  2643. -//Not used in CoWiki
  2644. -class Text_Wiki_Parse_Image extends Text_Wiki_Parse {
  2645. -
  2646. -
  2647. + * Parses for image placement.
  2648. + *
  2649. + * Not used in CoWiki
  2650. + *
  2651. + * @category Text
  2652. + * @package Text_Wiki
  2653. + * @author Paul M. Jones <pmjones@php.net>
  2654. + * @copyright 2005 Paul M. Jones
  2655. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2656. + * @version Release: @package_version@
  2657. + * @link http://pear.php.net/package/Text_Wiki
  2658. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2659. + */
  2660. +class Text_Wiki_Parse_Image extends Text_Wiki_Parse
  2661. +{
  2662. +
  2663. +
  2664. /**
  2665. - *
  2666. - * The regular expression used to find source text matching this
  2667. - * rule.
  2668. - *
  2669. - * @access public
  2670. - *
  2671. - * @var string
  2672. - *
  2673. - */
  2674. -
  2675. + * The regular expression used to parse the source text and find
  2676. + * matches conforming to this rule. Used by the parse() method.
  2677. + *
  2678. + * @access public
  2679. + *
  2680. + * @var string
  2681. + *
  2682. + * @see parse()
  2683. + */
  2684. var $regex = '/({img )(.+?)(})/i';
  2685. -
  2686. -
  2687. +
  2688. +
  2689. /**
  2690. - *
  2691. - * Generates a token entry for the matched text. Token options are:
  2692. - *
  2693. - * 'src' => The image source, typically a relative path name.
  2694. - *
  2695. - * 'opts' => Any macro options following the source.
  2696. - *
  2697. - * @access public
  2698. - *
  2699. - * @param array &$matches The array of matches from parse().
  2700. - *
  2701. - * @return A delimited token number to be used as a placeholder in
  2702. - * the source text.
  2703. - *
  2704. - */
  2705. -
  2706. + * Generates a token entry for the matched text. Token options are:
  2707. + *
  2708. + * 'src' => The image source, typically a relative path name.
  2709. + *
  2710. + * 'opts' => Any macro options following the source.
  2711. + *
  2712. + * @param array &$matches The array of matches from parse().
  2713. + *
  2714. + * @access public
  2715. + * @return A delimited token number to be used as a placeholder in
  2716. + * the source text.
  2717. + */
  2718. +
  2719. function process(&$matches)
  2720. {
  2721. $pos = strpos($matches[2], ' ');
  2722. -
  2723. +
  2724. if ($pos === false) {
  2725. $options = array(
  2726. 'src' => $matches[2],
  2727. @@ -78,8 +72,8 @@
  2728. 'attr' => $this->getAttrs(substr($matches[2], $pos+1))
  2729. );
  2730. }
  2731. -
  2732. +
  2733. return $this->wiki->addToken($this->rule, $options);
  2734. }
  2735. }
  2736. -?>
  2737. \ No newline at end of file
  2738. +?>
  2739. Index: Text/Wiki/Parse/Cowiki/Include.php
  2740. ===================================================================
  2741. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Include.php,v
  2742. retrieving revision 1.1
  2743. diff -u -r1.1 Include.php
  2744. --- Text/Wiki/Parse/Cowiki/Include.php 21 Jul 2005 20:56:13 -0000 1.1
  2745. +++ Text/Wiki/Parse/Cowiki/Include.php 28 Oct 2008 02:23:52 -0000
  2746. @@ -1,82 +1,74 @@
  2747. <?php
  2748. -
  2749. /**
  2750. -*
  2751. -* Includes the contents of another PHP script into the source text.
  2752. -*
  2753. -* @category Text
  2754. -*
  2755. -* @package Text_Wiki
  2756. -*
  2757. -* @author Paul M. Jones <pmjones@php.net>
  2758. -*
  2759. -* @license LGPL
  2760. -*
  2761. -* @version $Id: Include.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2762. -*
  2763. -*/
  2764. + * Includes the contents of another PHP script into the source text.
  2765. + *
  2766. + * PHP version 4, 5
  2767. + *
  2768. + * @category Text
  2769. + * @package Text_Wiki
  2770. + * @author Paul M. Jones <pmjones@php.net>
  2771. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2772. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2773. + * @link http://pear.php.net/package/Text_Wiki
  2774. + */
  2775.  
  2776. /**
  2777. -*
  2778. -* This class implements a Text_Wiki_Parse to include the results of a
  2779. -* script directly into the source at parse-time; thus, the output of the
  2780. -* script will be parsed by Text_Wiki. This differs from the 'embed'
  2781. -* rule, which incorporates the results at render-time, meaning that the
  2782. -* 'embed' content is not parsed by Text_Wiki.
  2783. -*
  2784. -* DANGER!
  2785. -*
  2786. -* This rule is inherently not secure; it allows cross-site scripting to
  2787. -* occur if the embedded output has <script> or other similar tags. Be
  2788. -* careful.
  2789. -*
  2790. -* @category Text
  2791. -*
  2792. -* @package Text_Wiki
  2793. -*
  2794. -* @author Paul M. Jones <pmjones@php.net>
  2795. -*
  2796. -*/
  2797. -//None in CoWIki
  2798. -class Text_Wiki_Parse_Include extends Text_Wiki_Parse {
  2799. -
  2800. + * This class implements a Text_Wiki_Parse to include the results of a
  2801. + * script directly into the source at parse-time; thus, the output of the
  2802. + * script will be parsed by Text_Wiki. This differs from the 'embed'
  2803. + * rule, which incorporates the results at render-time, meaning that the
  2804. + * 'embed' content is not parsed by Text_Wiki.
  2805. + *
  2806. + * DANGER!
  2807. + *
  2808. + * This rule is inherently not secure; it allows cross-site scripting to
  2809. + * occur if the embedded output has <script> or other similar tags. Be
  2810. + * careful.
  2811. + *
  2812. + * @category Text
  2813. + * @package Text_Wiki
  2814. + * @author Paul M. Jones <pmjones@php.net>
  2815. + * @copyright 2005 Paul M. Jones
  2816. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2817. + * @version Release: @package_version@
  2818. + * @link http://pear.php.net/package/Text_Wiki
  2819. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2820. + */
  2821. +class Text_Wiki_Parse_Include extends Text_Wiki_Parse
  2822. +{
  2823. +
  2824. var $conf = array(
  2825. 'base' => '/path/to/scripts/'
  2826. );
  2827. -
  2828. +
  2829. var $file = null;
  2830. -
  2831. +
  2832. var $output = null;
  2833. -
  2834. +
  2835. var $vars = null;
  2836.  
  2837. /**
  2838. - *
  2839. - * The regular expression used to find source text matching this
  2840. - * rule.
  2841. - *
  2842. - * @access public
  2843. - *
  2844. - * @var string
  2845. - *
  2846. - */
  2847. -
  2848. + * The regular expression used to parse the source text and find
  2849. + * matches conforming to this rule. Used by the parse() method.
  2850. + *
  2851. + * @access public
  2852. + *
  2853. + * @var string
  2854. + *
  2855. + * @see parse()
  2856. + */
  2857. var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i';
  2858. -
  2859. -
  2860. +
  2861. +
  2862. /**
  2863. - *
  2864. - * Includes the results of the script directly into the source; the output
  2865. - * will subsequently be parsed by the remaining Text_Wiki rules.
  2866. - *
  2867. - * @access public
  2868. - *
  2869. - * @param array &$matches The array of matches from parse().
  2870. - *
  2871. - * @return The results of the included script.
  2872. - *
  2873. - */
  2874. -
  2875. + * Includes the results of the script directly into the source; the output
  2876. + * will subsequently be parsed by the remaining Text_Wiki rules.
  2877. + *
  2878. + * @param array &$matches The array of matches from parse().
  2879. + *
  2880. + * @access public
  2881. + * @return The results of the included script.
  2882. + */
  2883. function process(&$matches)
  2884. {
  2885. // save the file location
  2886. @@ -89,12 +81,12 @@
  2887.  
  2888. // run the script
  2889. ob_start();
  2890. - include($this->file);
  2891. + include $this->file;
  2892. $this->output = ob_get_contents();
  2893. ob_end_clean();
  2894. -
  2895. +
  2896. // done, place the script output directly in the source
  2897. return $this->output;
  2898. }
  2899. }
  2900. -?>
  2901. \ No newline at end of file
  2902. +?>
  2903. Index: Text/Wiki/Parse/Cowiki/Interwiki.php
  2904. ===================================================================
  2905. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Interwiki.php,v
  2906. retrieving revision 1.2
  2907. diff -u -r1.2 Interwiki.php
  2908. --- Text/Wiki/Parse/Cowiki/Interwiki.php 28 Feb 2006 02:26:29 -0000 1.2
  2909. +++ Text/Wiki/Parse/Cowiki/Interwiki.php 28 Oct 2008 02:23:52 -0000
  2910. @@ -1,129 +1,122 @@
  2911. <?php
  2912. -
  2913. /**
  2914. -*
  2915. -* Parses for interwiki links.
  2916. -*
  2917. -* @category Text
  2918. -*
  2919. -* @package Text_Wiki
  2920. -*
  2921. -* @author Paul M. Jones <pmjones@php.net>
  2922. -*
  2923. -* @license LGPL
  2924. -*
  2925. -* @version $Id: Interwiki.php,v 1.2 2006/02/28 02:26:29 justinpatrin Exp $
  2926. -*
  2927. -*/
  2928. + * Parses for interwiki links.
  2929. + *
  2930. + * PHP version 4, 5
  2931. + *
  2932. + * @category Text
  2933. + * @package Text_Wiki
  2934. + * @author Paul M. Jones <pmjones@php.net>
  2935. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2936. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  2937. + * @link http://pear.php.net/package/Text_Wiki
  2938. + */
  2939.  
  2940. /**
  2941. -*
  2942. -* Parses for interwiki links.
  2943. -*
  2944. -* This class implements a Text_Wiki_Parse to find source text marked as
  2945. -* an Interwiki link. See the regex for a detailed explanation of the
  2946. -* text matching procedure; e.g., "InterWikiName:PageName".
  2947. -*
  2948. -* @category Text
  2949. -*
  2950. -* @package Text_Wiki
  2951. -*
  2952. -* @author Paul M. Jones <pmjones@php.net>
  2953. -*
  2954. -*/
  2955. + * Parses for interwiki links.
  2956. + *
  2957. + * This class implements a Text_Wiki_Parse to find source text marked as
  2958. + * an Interwiki link. See the regex for a detailed explanation of the
  2959. + * text matching procedure; e.g., "InterWikiName:PageName".
  2960. + *
  2961. + * @category Text
  2962. + * @package Text_Wiki
  2963. + * @author Paul M. Jones <pmjones@php.net>
  2964. + * @copyright 2005 Paul M. Jones
  2965. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  2966. + * @version Release: @package_version@
  2967. + * @link http://pear.php.net/package/Text_Wiki
  2968. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  2969. + */
  2970. +
  2971. +class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse
  2972. +{
  2973.  
  2974. -class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse {
  2975. -
  2976. // double-colons wont trip up now
  2977. var $regex = '([A-Za-z0-9_\s\.-:;&~=\/]+)\|((?!\|)[A-Za-z0-9_\/=&~#.:;-\s]*)';
  2978. -
  2979. -
  2980. +
  2981. +
  2982. /**
  2983. - *
  2984. - * Parser. We override the standard parser so we can
  2985. - * find both described interwiki links and standalone links.
  2986. - *
  2987. - * @access public
  2988. - *
  2989. - * @return void
  2990. - *
  2991. - */
  2992. -
  2993. + * Parser. We override the standard parser so we can
  2994. + * find both described interwiki links and standalone links.
  2995. + *
  2996. + * @access public
  2997. + *
  2998. + * @return void
  2999. + *
  3000. + */
  3001. +
  3002. function parse()
  3003. {
  3004. // described interwiki links
  3005. $tmp_regex = '/\(\(' . $this->regex . '(\)\((.+?))?\)\)/';
  3006. - $this->wiki->source = preg_replace_callback(
  3007. - $tmp_regex,
  3008. - array(&$this, 'processDescr'),
  3009. - $this->wiki->source
  3010. - );
  3011. -
  3012. +
  3013. + $this->wiki->source = preg_replace_callback($tmp_regex,
  3014. + array(&$this, 'processDescr'),
  3015. + $this->wiki->source);
  3016. +
  3017. // standalone interwiki links
  3018. $tmp_regex = '/' . $this->regex . '/';
  3019. - $this->wiki->source = preg_replace_callback(
  3020. - $tmp_regex,
  3021. - array(&$this, 'process'),
  3022. - $this->wiki->source
  3023. - );
  3024. -
  3025. +
  3026. + $this->wiki->source = preg_replace_callback($tmp_regex,
  3027. + array(&$this, 'process'),
  3028. + $this->wiki->source);
  3029. +
  3030. }
  3031. -
  3032. -
  3033. +
  3034. +
  3035. /**
  3036. - *
  3037. - * Generates a replacement for the matched standalone interwiki text.
  3038. - * Token options are:
  3039. - *
  3040. - * 'site' => The key name for the Text_Wiki interwiki array map,
  3041. - * usually the name of the interwiki site.
  3042. - *
  3043. - * 'page' => The page on the target interwiki to link to.
  3044. - *
  3045. - * 'text' => The text to display as the link.
  3046. - *
  3047. - * @access public
  3048. - *
  3049. - * @param array &$matches The array of matches from parse().
  3050. - *
  3051. - * @return A delimited token to be used as a placeholder in
  3052. - * the source text, plus any text priot to the match.
  3053. - *
  3054. - */
  3055. -
  3056. + * Generates a replacement for the matched standalone interwiki text.
  3057. + * Token options are:
  3058. + *
  3059. + * 'site' => The key name for the Text_Wiki interwiki array map,
  3060. + * usually the name of the interwiki site.
  3061. + *
  3062. + * 'page' => The page on the target interwiki to link to.
  3063. + *
  3064. + * 'text' => The text to display as the link.
  3065. + *
  3066. + * @param array &$matches The array of matches from parse().
  3067. + *
  3068. + * @access public
  3069. + * @return A delimited token to be used as a placeholder in
  3070. + * the source text, plus any text priot to the match.
  3071. + *
  3072. + */
  3073. +
  3074. function process(&$matches)
  3075. {
  3076. + $result = isset($matches[2]) && strlen($matches[2]);
  3077. +
  3078. $options = array(
  3079. 'site' => $matches[1],
  3080. 'page' => isset($matches[2]) ? $matches[2] : '',
  3081. - 'text' => isset($matches[2]) && strlen($matches[2]) ? $matches[2] : $matches[1]
  3082. + 'text' => $result ? $matches[2] : $matches[1]
  3083. );
  3084. -
  3085. +
  3086. return $this->wiki->addToken($this->rule, $options);
  3087. }
  3088. -
  3089. -
  3090. +
  3091. +
  3092. /**
  3093. - *
  3094. - * Generates a replacement for described interwiki links. Token
  3095. - * options are:
  3096. - *
  3097. - * 'site' => The key name for the Text_Wiki interwiki array map,
  3098. - * usually the name of the interwiki site.
  3099. - *
  3100. - * 'page' => The page on the target interwiki to link to.
  3101. - *
  3102. - * 'text' => The text to display as the link.
  3103. - *
  3104. - * @access public
  3105. - *
  3106. - * @param array &$matches The array of matches from parse().
  3107. - *
  3108. - * @return A delimited token to be used as a placeholder in
  3109. - * the source text, plus any text priot to the match.
  3110. - *
  3111. - */
  3112. -
  3113. + * Generates a replacement for described interwiki links. Token
  3114. + * options are:
  3115. + *
  3116. + * 'site' => The key name for the Text_Wiki interwiki array map,
  3117. + * usually the name of the interwiki site.
  3118. + *
  3119. + * 'page' => The page on the target interwiki to link to.
  3120. + *
  3121. + * 'text' => The text to display as the link.
  3122. + *
  3123. + * @param array &$matches The array of matches from parse().
  3124. + *
  3125. + * @access public
  3126. + * @return A delimited token to be used as a placeholder in
  3127. + * the source text, plus any text priot to the match.
  3128. + *
  3129. + */
  3130. +
  3131. function processDescr(&$matches)
  3132. {
  3133. $options = array(
  3134. @@ -135,8 +128,8 @@
  3135. ? $matches[2]
  3136. : $matches[1]))
  3137. );
  3138. -
  3139. +
  3140. return $this->wiki->addToken($this->rule, $options);
  3141. }
  3142. }
  3143. -?>
  3144. \ No newline at end of file
  3145. +?>
  3146. Index: Text/Wiki/Parse/Cowiki/Italic.php
  3147. ===================================================================
  3148. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Italic.php,v
  3149. retrieving revision 1.1
  3150. diff -u -r1.1 Italic.php
  3151. --- Text/Wiki/Parse/Cowiki/Italic.php 21 Jul 2005 20:56:13 -0000 1.1
  3152. +++ Text/Wiki/Parse/Cowiki/Italic.php 28 Oct 2008 02:23:52 -0000
  3153. @@ -1,79 +1,72 @@
  3154. <?php
  3155. -
  3156. /**
  3157. -*
  3158. -* Parses for italic text.
  3159. -*
  3160. -* @category Text
  3161. -*
  3162. -* @package Text_Wiki
  3163. -*
  3164. -* @author Paul M. Jones <pmjones@php.net>
  3165. -*
  3166. -* @license LGPL
  3167. -*
  3168. -* @version $Id: Italic.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3169. -*
  3170. -*/
  3171. + * Parses for italic text.
  3172. + *
  3173. + * PHP version 4, 5
  3174. + *
  3175. + * @category Text
  3176. + * @package Text_Wiki
  3177. + * @author Paul M. Jones <pmjones@php.net>
  3178. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3179. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3180. + * @link http://pear.php.net/package/Text_Wiki
  3181. + */
  3182.  
  3183. /**
  3184. -*
  3185. -* Parses for italic text.
  3186. -*
  3187. -* This class implements a Text_Wiki_Parse to find source text marked for
  3188. -* emphasis (italics) as defined by text surrounded by two single-quotes.
  3189. -* On parsing, the text itself is left in place, but the starting and ending
  3190. -* instances of two single-quotes are replaced with tokens.
  3191. -*
  3192. -* @category Text
  3193. -*
  3194. -* @package Text_Wiki
  3195. -*
  3196. -* @author Paul M. Jones <pmjones@php.net>
  3197. -*
  3198. -*/
  3199. + * Parses for italic text.
  3200. + *
  3201. + * This class implements a Text_Wiki_Parse to find source text marked for
  3202. + * emphasis (italics) as defined by text surrounded by two single-quotes.
  3203. + * On parsing, the text itself is left in place, but the starting and ending
  3204. + * instances of two single-quotes are replaced with tokens.
  3205. + *
  3206. + * @category Text
  3207. + * @package Text_Wiki
  3208. + * @author Paul M. Jones <pmjones@php.net>
  3209. + * @copyright 2005 Paul M. Jones
  3210. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3211. + * @version Release: @package_version@
  3212. + * @link http://pear.php.net/package/Text_Wiki
  3213. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  3214. + */
  3215. +
  3216. +class Text_Wiki_Parse_Italic extends Text_Wiki_Parse
  3217. +{
  3218.  
  3219. -class Text_Wiki_Parse_Italic extends Text_Wiki_Parse {
  3220. -
  3221. /**
  3222. * Setting regex in constructor instead of with var as we need $this->wiki->delim
  3223. + *
  3224. + * @param Text_Wiki &$obj Calling class
  3225. */
  3226. - function Text_Wiki_Parse_Italic(&$obj) {
  3227. + function Text_Wiki_Parse_Italic(&$obj)
  3228. + {
  3229. parent::Text_Wiki_Parse($obj);
  3230.  
  3231. - //using [^delim] here as CoWiki's Italic syntax is a single / and its other markup is HTML syntax with / in it
  3232. + //using [^delim] here as CoWiki's Italic syntax is a single
  3233. + // and its other markup is HTML syntax with / in it
  3234. // This rule *must* be applied after all HTML style rules
  3235. $this->regex = '=(?<!<)/(()|[^/]*?)/=';
  3236. }
  3237. -
  3238. +
  3239. /**
  3240. - *
  3241. - * Generates a replacement for the matched text. Token options are:
  3242. - *
  3243. - * 'type' => ['start'|'end'] The starting or ending point of the
  3244. - * emphasized text. The text itself is left in the source.
  3245. - *
  3246. - * @access public
  3247. - *
  3248. - * @param array &$matches The array of matches from parse().
  3249. - *
  3250. - * @return string A pair of delimited tokens to be used as a
  3251. - * placeholder in the source text surrounding the text to be
  3252. - * emphasized.
  3253. - *
  3254. - */
  3255. -
  3256. + * Generates a replacement for the matched text. Token options are:
  3257. + *
  3258. + * 'type' => ['start'|'end'] The starting or ending point of the
  3259. + * emphasized text. The text itself is left in the source.
  3260. + *
  3261. + * @param array &$matches The array of matches from parse().
  3262. + *
  3263. + * @access public
  3264. + * @return string A pair of delimited tokens to be used as a
  3265. + * placeholder in the source text surrounding the text to be
  3266. + * emphasized.
  3267. + */
  3268. function process(&$matches)
  3269. {
  3270. - $start = $this->wiki->addToken(
  3271. - $this->rule, array('type' => 'start')
  3272. - );
  3273. -
  3274. - $end = $this->wiki->addToken(
  3275. - $this->rule, array('type' => 'end')
  3276. - );
  3277. -
  3278. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  3279. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  3280. +
  3281. return $start . $matches[1] . $end;
  3282. }
  3283. }
  3284. -?>
  3285. \ No newline at end of file
  3286. +?>
  3287. Index: Text/Wiki/Parse/Cowiki/List.php
  3288. ===================================================================
  3289. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/List.php,v
  3290. retrieving revision 1.1
  3291. diff -u -r1.1 List.php
  3292. --- Text/Wiki/Parse/Cowiki/List.php 21 Jul 2005 20:56:13 -0000 1.1
  3293. +++ Text/Wiki/Parse/Cowiki/List.php 28 Oct 2008 02:23:52 -0000
  3294. @@ -1,127 +1,118 @@
  3295. <?php
  3296. -
  3297. /**
  3298. -*
  3299. -* Parses for bulleted and numbered lists.
  3300. -*
  3301. -* @category Text
  3302. -*
  3303. -* @package Text_Wiki
  3304. -*
  3305. -* @author Paul M. Jones <pmjones@php.net>
  3306. -*
  3307. -* @license LGPL
  3308. -*
  3309. -* @version $Id: List.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3310. -*
  3311. -*/
  3312. + * Parses for bulleted and numbered lists.
  3313. + *
  3314. + * PHP version 4, 5
  3315. + *
  3316. + * @category Text
  3317. + * @package Text_Wiki
  3318. + * @author Paul M. Jones <pmjones@php.net>
  3319. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3320. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3321. + * @link http://pear.php.net/package/Text_Wiki
  3322. + */
  3323.  
  3324. /**
  3325. -*
  3326. -* Parses for bulleted and numbered lists.
  3327. -*
  3328. -* This class implements a Text_Wiki_Parse to find source text marked as
  3329. -* a bulleted or numbered list. In short, if a line starts with '* ' then
  3330. -* it is a bullet list item; if a line starts with '# ' then it is a
  3331. -* number list item. Spaces in front of the * or # indicate an indented
  3332. -* sub-list. The list items must be on sequential lines, and may be
  3333. -* separated by blank lines to improve readability. Using a non-* non-#
  3334. -* non-whitespace character at the beginning of a line ends the list.
  3335. -*
  3336. -* @category Text
  3337. -*
  3338. -* @package Text_Wiki
  3339. -*
  3340. -* @author Paul M. Jones <pmjones@php.net>
  3341. -*
  3342. -*/
  3343. -
  3344. -class Text_Wiki_Parse_List extends Text_Wiki_Parse {
  3345. -
  3346. -
  3347. + * Parses for bulleted and numbered lists.
  3348. + *
  3349. + * This class implements a Text_Wiki_Parse to find source text marked as
  3350. + * a bulleted or numbered list. In short, if a line starts with '* ' then
  3351. + * it is a bullet list item; if a line starts with '# ' then it is a
  3352. + * number list item. Spaces in front of the * or # indicate an indented
  3353. + * sub-list. The list items must be on sequential lines, and may be
  3354. + * separated by blank lines to improve readability. Using a non-* non-#
  3355. + * non-whitespace character at the beginning of a line ends the list.
  3356. + *
  3357. + * @category Text
  3358. + * @package Text_Wiki
  3359. + * @author Paul M. Jones <pmjones@php.net>
  3360. + * @copyright 2005 Paul M. Jones
  3361. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3362. + * @version Release: @package_version@
  3363. + * @link http://pear.php.net/package/Text_Wiki
  3364. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  3365. + */
  3366. +class Text_Wiki_Parse_List extends Text_Wiki_Parse
  3367. +{
  3368. +
  3369. +
  3370. /**
  3371. - *
  3372. - * The regular expression used to parse the source text and find
  3373. - * matches conforming to this rule. Used by the parse() method.
  3374. - *
  3375. - * @access public
  3376. - *
  3377. - * @var string
  3378. - *
  3379. - * @see parse()
  3380. - *
  3381. - */
  3382. -
  3383. + * The regular expression used to parse the source text and find
  3384. + * matches conforming to this rule. Used by the parse() method.
  3385. + *
  3386. + * @access public
  3387. + *
  3388. + * @var string
  3389. + *
  3390. + * @see parse()
  3391. + *
  3392. + */
  3393. +
  3394. var $regex = '/\n(( *)[\*#] .*\n(?!( *)(\*|#)+))/Us';
  3395.  
  3396. /**
  3397. - *
  3398. - * Generates a replacement for the matched text. Token options are:
  3399. - *
  3400. - * 'type' =>
  3401. - * 'bullet_start' : the start of a bullet list
  3402. - * 'bullet_end' : the end of a bullet list
  3403. - * 'number_start' : the start of a number list
  3404. - * 'number_end' : the end of a number list
  3405. - * 'item_start' : the start of item text (bullet or number)
  3406. - * 'item_end' : the end of item text (bullet or number)
  3407. - * 'unknown' : unknown type of list or item
  3408. - *
  3409. - * 'level' => the indent level (0 for the first level, 1 for the
  3410. - * second, etc)
  3411. - *
  3412. - * 'count' => the list item number at this level. not needed for
  3413. - * xhtml, but very useful for PDF and RTF.
  3414. - *
  3415. - * @access public
  3416. - *
  3417. - * @param array &$matches The array of matches from parse().
  3418. - *
  3419. - * @return A series of text and delimited tokens marking the different
  3420. - * list text and list elements.
  3421. - *
  3422. - */
  3423. -
  3424. + * Generates a replacement for the matched text. Token options are:
  3425. + *
  3426. + * 'type' =>
  3427. + * 'bullet_start' : the start of a bullet list
  3428. + * 'bullet_end' : the end of a bullet list
  3429. + * 'number_start' : the start of a number list
  3430. + * 'number_end' : the end of a number list
  3431. + * 'item_start' : the start of item text (bullet or number)
  3432. + * 'item_end' : the end of item text (bullet or number)
  3433. + * 'unknown' : unknown type of list or item
  3434. + *
  3435. + * 'level' => the indent level (0 for the first level, 1 for the
  3436. + * second, etc)
  3437. + *
  3438. + * 'count' => the list item number at this level. not needed for
  3439. + * xhtml, but very useful for PDF and RTF.
  3440. + *
  3441. + * @param array &$matches The array of matches from parse().
  3442. + *
  3443. + * @access public
  3444. + * @return A series of text and delimited tokens marking the different
  3445. + * list text and list elements.
  3446. + *
  3447. + */
  3448. function process(&$matches)
  3449. {
  3450. // the replacement text we will return
  3451. $return = '';
  3452. -
  3453. +
  3454. // the list of post-processing matches
  3455. $list = array();
  3456. -
  3457. +
  3458. // a stack of list-start and list-end types; we keep this
  3459. // so that we know what kind of list we're working with
  3460. // (bullet or number) and what indent level we're at.
  3461. $stack = array();
  3462. -
  3463. +
  3464. // the item count is the number of list items for any
  3465. // given list-type on the stack
  3466. $itemcount = array();
  3467. -
  3468. +
  3469. // have we processed the very first list item?
  3470. $pastFirst = false;
  3471. -
  3472. +
  3473. // populate $list with this set of matches. $matches[1] is the
  3474. // text matched as a list set by parse().
  3475. - preg_match_all(
  3476. - '/^( *)([\*#]) (.*)$/Ums',
  3477. - $matches[1],
  3478. - $list,
  3479. - PREG_SET_ORDER
  3480. - );
  3481. -
  3482. + preg_match_all('/^( *)([\*#]) (.*)$/Ums',
  3483. + $matches[1],
  3484. + $list,
  3485. + PREG_SET_ORDER);
  3486. +
  3487. // loop through each list-item element.
  3488. foreach ($list as $key => $val) {
  3489. // $val[0] is the full matched list-item line
  3490. // $val[1] is the type (* or #)
  3491. // $val[2] is the level (number)
  3492. // $val[3] is the list item text
  3493. -
  3494. +
  3495. // how many levels are we indented? (1 means the "root"
  3496. // list level, no indenting.)
  3497. $level = strlen($val[1]) + 1;
  3498. -
  3499. +
  3500. // get the list item type
  3501. if ($val[2] == '*') {
  3502. $type = 'bullet';
  3503. @@ -130,58 +121,51 @@
  3504. } else {
  3505. $type = 'unknown';
  3506. }
  3507. -
  3508. +
  3509. // get the text of the list item
  3510. $text = $val[3];
  3511.  
  3512. // add a level to the list?
  3513. if ($level > count($stack)) {
  3514. -
  3515. +
  3516. // the current indent level is greater than the
  3517. // number of stack elements, so we must be starting
  3518. // a new list. push the new list type onto the
  3519. // stack...
  3520. array_push($stack, $type);
  3521. -
  3522. +
  3523. // ...and add a list-start token to the return.
  3524. - $return .= $this->wiki->addToken(
  3525. - $this->rule,
  3526. - array(
  3527. - 'type' => $type . '_list_start',
  3528. - 'level' => $level - 1
  3529. - )
  3530. - );
  3531. + $options = array('type' => $type . '_list_start',
  3532. + 'level' => $level - 1);
  3533. + $return .= $this->wiki->addToken($this->rule, $options);
  3534. }
  3535. -
  3536. +
  3537. // remove a level from the list?
  3538. while (count($stack) > $level) {
  3539. -
  3540. +
  3541. // so we don't keep counting the stack, we set up a temp
  3542. // var for the count. -1 becuase we're going to pop the
  3543. // stack in the next command. $tmp will then equal the
  3544. // current level of indent.
  3545. $tmp = count($stack) - 1;
  3546. -
  3547. +
  3548. // as long as the stack count is greater than the
  3549. - // current indent level, we need to end list types.
  3550. + // current indent level, we need to end list types.
  3551. // continue adding end-list tokens until the stack count
  3552. // and the indent level are the same.
  3553. - $return .= $this->wiki->addToken(
  3554. - $this->rule,
  3555. - array (
  3556. - 'type' => array_pop($stack) . '_list_end',
  3557. - 'level' => $tmp
  3558. - )
  3559. - );
  3560. -
  3561. + $options = array ('type' => array_pop($stack) . '_list_end',
  3562. + 'level' => $tmp);
  3563. +
  3564. + $return .= $this->wiki->addToken($this->rule, $options);
  3565. +
  3566. // reset to the current (previous) list type so that
  3567. // the new list item matches the proper list type.
  3568. $type = $stack[$tmp - 1];
  3569. -
  3570. +
  3571. // reset the item count for the popped indent level
  3572. unset($itemcount[$tmp + 1]);
  3573. }
  3574. -
  3575. +
  3576. // add to the item count for this list (taking into account
  3577. // which level we are at).
  3578. if (! isset($itemcount[$level])) {
  3579. @@ -191,56 +175,51 @@
  3580. // increment count
  3581. $itemcount[$level]++;
  3582. }
  3583. -
  3584. +
  3585. // is this the very first item in the list?
  3586. - if (! $pastFirst) {
  3587. + if (!$pastFirst) {
  3588. $first = true;
  3589. +
  3590. $pastFirst = true;
  3591. } else {
  3592. $first = false;
  3593. }
  3594. -
  3595. +
  3596. // create a list-item starting token.
  3597. - $start = $this->wiki->addToken(
  3598. - $this->rule,
  3599. - array(
  3600. - 'type' => $type . '_item_start',
  3601. - 'level' => $level,
  3602. - 'count' => $itemcount[$level],
  3603. - 'first' => $first
  3604. - )
  3605. - );
  3606. -
  3607. + $options = array(
  3608. + 'type' => $type . '_item_start',
  3609. + 'level' => $level,
  3610. + 'count' => $itemcount[$level],
  3611. + 'first' => $first
  3612. + );
  3613. +
  3614. + $start = $this->wiki->addToken($this->rule, $options);
  3615. +
  3616. // create a list-item ending token.
  3617. - $end = $this->wiki->addToken(
  3618. - $this->rule,
  3619. - array(
  3620. - 'type' => $type . '_item_end',
  3621. - 'level' => $level,
  3622. - 'count' => $itemcount[$level]
  3623. - )
  3624. - );
  3625. -
  3626. + $end = $this->wiki->addToken($this->rule,
  3627. + array(
  3628. + 'type' => $type . '_item_end',
  3629. + 'level' => $level,
  3630. + 'count' => $itemcount[$level]
  3631. + ));
  3632. +
  3633. // add the starting token, list-item text, and ending token
  3634. // to the return.
  3635. $return .= $start . $text . $end;
  3636. }
  3637. -
  3638. +
  3639. // the last list-item may have been indented. go through the
  3640. // list-type stack and create end-list tokens until the stack
  3641. // is empty.
  3642. while (count($stack) > 0) {
  3643. - $return .= $this->wiki->addToken(
  3644. - $this->rule,
  3645. - array (
  3646. - 'type' => array_pop($stack) . '_list_end',
  3647. - 'level' => count($stack)
  3648. - )
  3649. - );
  3650. + $options = array('type' => array_pop($stack) . '_list_end',
  3651. + 'level' => count($stack));
  3652. +
  3653. + $return .= $this->wiki->addToken($this->rule, $options);
  3654. }
  3655. -
  3656. +
  3657. // we're done! send back the replacement text.
  3658. return "\n" . $return . "\n\n";
  3659. }
  3660. }
  3661. -?>
  3662. \ No newline at end of file
  3663. +?>
  3664. Index: Text/Wiki/Parse/Cowiki/Newline.php
  3665. ===================================================================
  3666. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Newline.php,v
  3667. retrieving revision 1.1
  3668. diff -u -r1.1 Newline.php
  3669. --- Text/Wiki/Parse/Cowiki/Newline.php 21 Jul 2005 20:56:13 -0000 1.1
  3670. +++ Text/Wiki/Parse/Cowiki/Newline.php 28 Oct 2008 02:23:52 -0000
  3671. @@ -1,75 +1,71 @@
  3672. <?php
  3673.  
  3674. /**
  3675. -*
  3676. -* Parses for implied line breaks indicated by newlines.
  3677. -*
  3678. -* @category Text
  3679. -*
  3680. -* @package Text_Wiki
  3681. -*
  3682. -* @author Paul M. Jones <pmjones@php.net>
  3683. -*
  3684. -* @license LGPL
  3685. -*
  3686. -* @version $Id: Newline.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3687. -*
  3688. -*/
  3689. + * Parses for implied line breaks indicated by newlines.
  3690. +*
  3691. + * PHP version 4, 5
  3692. + *
  3693. + * @category Text
  3694. + * @package Text_Wiki
  3695. + * @author Paul M. Jones <pmjones@php.net>
  3696. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3697. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3698. + * @link http://pear.php.net/package/Text_Wiki
  3699. + */
  3700.  
  3701. /**
  3702. -*
  3703. -* Parses for implied line breaks indicated by newlines.
  3704. -*
  3705. + * Parses for implied line breaks indicated by newlines.
  3706. +*
  3707. * This class implements a Text_Wiki_Parse to mark implied line breaks in the
  3708. * source text, usually a single carriage return in the middle of a paragraph
  3709. * or block-quoted text.
  3710. *
  3711. -* @category Text
  3712. -*
  3713. -* @package Text_Wiki
  3714. -*
  3715. -* @author Paul M. Jones <pmjones@php.net>
  3716. -*
  3717. -*/
  3718. -
  3719. -class Text_Wiki_Parse_Newline extends Text_Wiki_Parse {
  3720. -
  3721. -
  3722. + * @category Text
  3723. + * @package Text_Wiki
  3724. + * @author Paul M. Jones <pmjones@php.net>
  3725. + * @copyright 2005 Paul M. Jones
  3726. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3727. + * @version Release: @package_version@
  3728. + * @link http://pear.php.net/package/Text_Wiki
  3729. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  3730. + */
  3731. +
  3732. +class Text_Wiki_Parse_Newline extends Text_Wiki_Parse
  3733. +{
  3734. +
  3735. +
  3736. /**
  3737. - *
  3738. - * The regular expression used to parse the source text and find
  3739. - * matches conforming to this rule. Used by the parse() method.
  3740. - *
  3741. - * @access public
  3742. - *
  3743. - * @var string
  3744. - *
  3745. - * @see parse()
  3746. - *
  3747. - */
  3748. -
  3749. + *
  3750. + * The regular expression used to parse the source text and find
  3751. + * matches conforming to this rule. Used by the parse() method.
  3752. + *
  3753. + * @access public
  3754. + *
  3755. + * @var string
  3756. + *
  3757. + * @see parse()
  3758. + *
  3759. + */
  3760. +
  3761. var $regex = '/([^\n])\n([^\n])/m';
  3762. -
  3763. -
  3764. +
  3765. +
  3766. /**
  3767. - *
  3768. - * Generates a replacement token for the matched text.
  3769. - *
  3770. - * @access public
  3771. - *
  3772. - * @param array &$matches The array of matches from parse().
  3773. - *
  3774. - * @return string A delimited token to be used as a placeholder in
  3775. - * the source text.
  3776. - *
  3777. - */
  3778. -
  3779. + * Generates a replacement token for the matched text.
  3780. + *
  3781. + * @param array &$matches The array of matches from parse().
  3782. + *
  3783. + * @access public
  3784. + * @return string A delimited token to be used as a placeholder in
  3785. + * the source text.
  3786. + *
  3787. + */
  3788. function process(&$matches)
  3789. - {
  3790. + {
  3791. return $matches[1] .
  3792. $this->wiki->addToken($this->rule) .
  3793. $matches[2];
  3794. }
  3795. }
  3796.  
  3797. -?>
  3798. \ No newline at end of file
  3799. +?>
  3800. Index: Text/Wiki/Parse/Cowiki/Paragraph.php
  3801. ===================================================================
  3802. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Paragraph.php,v
  3803. retrieving revision 1.1
  3804. diff -u -r1.1 Paragraph.php
  3805. --- Text/Wiki/Parse/Cowiki/Paragraph.php 21 Jul 2005 20:56:13 -0000 1.1
  3806. +++ Text/Wiki/Parse/Cowiki/Paragraph.php 28 Oct 2008 02:23:52 -0000
  3807. @@ -1,52 +1,48 @@
  3808. <?php
  3809. -
  3810. /**
  3811. -*
  3812. -* Parses for paragraph blocks.
  3813. -*
  3814. -* @category Text
  3815. -*
  3816. -* @package Text_Wiki
  3817. -*
  3818. -* @author Paul M. Jones <pmjones@php.net>
  3819. -*
  3820. -* @license LGPL
  3821. -*
  3822. -* @version $Id: Paragraph.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3823. -*
  3824. -*/
  3825. + * Parses for paragraph blocks.
  3826. + *
  3827. + * PHP version 4, 5
  3828. + *
  3829. + * @category Text
  3830. + * @package Text_Wiki
  3831. + * @author Paul M. Jones <pmjones@php.net>
  3832. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3833. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  3834. + * @link http://pear.php.net/package/Text_Wiki
  3835. + */
  3836.  
  3837. /**
  3838. -*
  3839. -* Parses for paragraph blocks.
  3840. -*
  3841. -* This class implements a Text_Wiki rule to find sections of the source
  3842. -* text that are paragraphs. A para is any line not starting with a token
  3843. -* delimiter, followed by two newlines.
  3844. -*
  3845. -* @category Text
  3846. -*
  3847. -* @package Text_Wiki
  3848. -*
  3849. -* @author Paul M. Jones <pmjones@php.net>
  3850. -*
  3851. -*/
  3852. + * Parses for paragraph blocks.
  3853. + *
  3854. + * This class implements a Text_Wiki rule to find sections of the source
  3855. + * text that are paragraphs. A para is any line not starting with a token
  3856. + * delimiter, followed by two newlines.
  3857. + *
  3858. + * @category Text
  3859. + * @package Text_Wiki
  3860. + * @author Paul M. Jones <pmjones@php.net>
  3861. + * @copyright 2005 Paul M. Jones
  3862. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  3863. + * @version Release: @package_version@
  3864. + * @link http://pear.php.net/package/Text_Wiki
  3865. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  3866. + */
  3867. +class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse
  3868. +{
  3869.  
  3870. -class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse {
  3871. -
  3872. /**
  3873. - *
  3874. - * The regular expression used to find source text matching this
  3875. - * rule.
  3876. - *
  3877. - * @access public
  3878. - *
  3879. - * @var string
  3880. - *
  3881. - */
  3882. -
  3883. + * The regular expression used to find source text matching this
  3884. + * rule.
  3885. + *
  3886. + * @access public
  3887. + *
  3888. + * @var string
  3889. + *
  3890. + */
  3891. +
  3892. var $regex = "/^.*?\n\n/m";
  3893. -
  3894. +
  3895. var $conf = array(
  3896. 'skip' => array(
  3897. 'blockquote', // are we sure about this one?
  3898. @@ -59,53 +55,44 @@
  3899. 'toc'
  3900. )
  3901. );
  3902. -
  3903. -
  3904. +
  3905. +
  3906. /**
  3907. - *
  3908. - * Generates a token entry for the matched text. Token options are:
  3909. - *
  3910. - * 'start' => The starting point of the paragraph.
  3911. - *
  3912. - * 'end' => The ending point of the paragraph.
  3913. - *
  3914. - * @access public
  3915. - *
  3916. - * @param array &$matches The array of matches from parse().
  3917. - *
  3918. - * @return A delimited token number to be used as a placeholder in
  3919. - * the source text.
  3920. - *
  3921. - */
  3922. -
  3923. + * Generates a token entry for the matched text. Token options are:
  3924. + *
  3925. + * 'start' => The starting point of the paragraph.
  3926. + *
  3927. + * 'end' => The ending point of the paragraph.
  3928. + *
  3929. + * @param array &$matches The array of matches from parse().
  3930. + *
  3931. + * @access public
  3932. + * @return A delimited token number to be used as a placeholder in
  3933. + * the source text.
  3934. + */
  3935. function process(&$matches)
  3936. {
  3937. $delim = $this->wiki->delim;
  3938. -
  3939. +
  3940. // was anything there?
  3941. if (trim($matches[0]) == '') {
  3942. return '';
  3943. }
  3944. -
  3945. +
  3946. // does the match start with a delimiter?
  3947. - if (substr($matches[0], 0, 1) != $delim) {
  3948. + if (substr($matches[0], 0, 1) != $delim) {
  3949. // no.
  3950. -
  3951. - $start = $this->wiki->addToken(
  3952. - $this->rule, array('type' => 'start')
  3953. - );
  3954. -
  3955. - $end = $this->wiki->addToken(
  3956. - $this->rule, array('type' => 'end')
  3957. - );
  3958. -
  3959. +
  3960. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  3961. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  3962. +
  3963. return $start . trim($matches[0]) . $end;
  3964. }
  3965. -
  3966. +
  3967. // the line starts with a delimiter. read in the delimited
  3968. // token number, check the token, and see if we should
  3969. // skip it.
  3970. -
  3971. +
  3972. // loop starting at the second character (we already know
  3973. // the first is a delimiter) until we find another
  3974. // delimiter; the text between them is a token key number.
  3975. @@ -119,28 +106,24 @@
  3976. $key .= $char;
  3977. }
  3978. }
  3979. -
  3980. +
  3981. // look at the token and see if it's skippable (if we skip,
  3982. // it will not be marked as a paragraph)
  3983. $token_type = strtolower($this->wiki->tokens[$key][0]);
  3984. +
  3985. $skip = $this->getConf('skip', array());
  3986. -
  3987. +
  3988. if (in_array($token_type, $skip)) {
  3989. // this type of token should not have paragraphs applied to it.
  3990. // return the entire matched text.
  3991. return $matches[0];
  3992. } else {
  3993. -
  3994. - $start = $this->wiki->addToken(
  3995. - $this->rule, array('type' => 'start')
  3996. - );
  3997. -
  3998. - $end = $this->wiki->addToken(
  3999. - $this->rule, array('type' => 'end')
  4000. - );
  4001. -
  4002. +
  4003. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  4004. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  4005. +
  4006. return $start . trim($matches[0]) . $end;
  4007. }
  4008. }
  4009. }
  4010. -?>
  4011. \ No newline at end of file
  4012. +?>
  4013. Index: Text/Wiki/Parse/Cowiki/Phplookup.php
  4014. ===================================================================
  4015. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Phplookup.php,v
  4016. retrieving revision 1.1
  4017. diff -u -r1.1 Phplookup.php
  4018. --- Text/Wiki/Parse/Cowiki/Phplookup.php 21 Jul 2005 20:56:13 -0000 1.1
  4019. +++ Text/Wiki/Parse/Cowiki/Phplookup.php 28 Oct 2008 02:23:52 -0000
  4020. @@ -1,73 +1,61 @@
  4021. <?php
  4022. -
  4023. /**
  4024. -*
  4025. -* Find source text marked for lookup in the PHP online manual.
  4026. -*
  4027. -* @category Text
  4028. -*
  4029. -* @package Text_Wiki
  4030. -*
  4031. -* @author Paul M. Jones <pmjones@php.net>
  4032. -*
  4033. -* @license LGPL
  4034. -*
  4035. -* @version $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4036. -*
  4037. -*/
  4038. + * Find source text marked for lookup in the PHP online manual.
  4039. + *
  4040. + * PHP version 4, 5
  4041. + *
  4042. + * @category Text
  4043. + * @package Text_Wiki
  4044. + * @author Paul M. Jones <pmjones@php.net>
  4045. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4046. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4047. + * @link http://pear.php.net/package/Text_Wiki
  4048. + */
  4049.  
  4050. /**
  4051. -*
  4052. -* Find source text marked for lookup in the PHP online manual.
  4053. -*
  4054. -* @category Text
  4055. -*
  4056. -* @package Text_Wiki
  4057. -*
  4058. -* @author Paul M. Jones <pmjones@php.net>
  4059. -*
  4060. -*/
  4061. -//Nine in CoWIki
  4062. -class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse {
  4063. -
  4064. -
  4065. + * Find source text marked for lookup in the PHP online manual.
  4066. + * Nine in CoWIki
  4067. + *
  4068. + * @category Text
  4069. + * @package Text_Wiki
  4070. + * @author Paul M. Jones <pmjones@php.net>
  4071. + * @copyright 2005 Paul M. Jones
  4072. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4073. + * @version Release: @package_version@
  4074. + * @link http://pear.php.net/package/Text_Wiki
  4075. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  4076. + */
  4077. +class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse
  4078. +{
  4079. +
  4080. +
  4081. /**
  4082. - *
  4083. - * The regular expression used to parse the source text and find
  4084. - * matches conforming to this rule. Used by the parse() method.
  4085. - *
  4086. - * @access public
  4087. - *
  4088. - * @var string
  4089. - *
  4090. - * @see parse()
  4091. - *
  4092. - */
  4093. -
  4094. + * The regular expression used to parse the source text and find
  4095. + * matches conforming to this rule. Used by the parse() method.
  4096. + *
  4097. + * @access public
  4098. + *
  4099. + * @var string
  4100. + *
  4101. + * @see parse()
  4102. + */
  4103. var $regex = "/\[\[php (.+?)\]\]/";
  4104. -
  4105. -
  4106. +
  4107. +
  4108. /**
  4109. - *
  4110. - * Generates a replacement for the matched text. Token options are:
  4111. - *
  4112. - * 'type' => ['start'|'end'] The starting or ending point of the
  4113. - * teletype text. The text itself is left in the source.
  4114. - *
  4115. - * @access public
  4116. - *
  4117. - * @param array &$matches The array of matches from parse().
  4118. - *
  4119. - * @return string A pair of delimited tokens to be used as a
  4120. - * placeholder in the source text surrounding the teletype text.
  4121. - *
  4122. - */
  4123. -
  4124. + * Generates a replacement for the matched text. Token options are:
  4125. + * 'type' => ['start'|'end'] The starting or ending point of the
  4126. + * teletype text. The text itself is left in the source.
  4127. + *
  4128. + * @param array &$matches The array of matches from parse().
  4129. + *
  4130. + * @return string A pair of delimited tokens to be used as a
  4131. + * placeholder in the source text surrounding the teletype text.
  4132. + * @access public
  4133. + */
  4134. function process(&$matches)
  4135. {
  4136. - return $this->wiki->addToken(
  4137. - $this->rule, array('text' => $matches[1])
  4138. - );
  4139. + return $this->wiki->addToken($this->rule, array('text' => $matches[1]));
  4140. }
  4141. }
  4142. -?>
  4143. \ No newline at end of file
  4144. +?>
  4145. Index: Text/Wiki/Parse/Cowiki/Prefilter.php
  4146. ===================================================================
  4147. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Prefilter.php,v
  4148. retrieving revision 1.1
  4149. diff -u -r1.1 Prefilter.php
  4150. --- Text/Wiki/Parse/Cowiki/Prefilter.php 21 Jul 2005 20:56:13 -0000 1.1
  4151. +++ Text/Wiki/Parse/Cowiki/Prefilter.php 28 Oct 2008 02:23:52 -0000
  4152. @@ -1,78 +1,74 @@
  4153. <?php
  4154. -
  4155. /**
  4156. -*
  4157. -* "Pre-filter" the source text.
  4158. -*
  4159. -* @category Text
  4160. -*
  4161. -* @package Text_Wiki
  4162. -*
  4163. -* @author Paul M. Jones <pmjones@php.net>
  4164. -*
  4165. -* @license LGPL
  4166. -*
  4167. -* @version $Id: Prefilter.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4168. -*
  4169. -*/
  4170. + * "Pre-filter" the source text.
  4171. + *
  4172. + * PHP version 4, 5
  4173. + *
  4174. + * @category Text
  4175. + * @package Text_Wiki
  4176. + * @author Paul M. Jones <pmjones@php.net>
  4177. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4178. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4179. + * @link http://pear.php.net/package/Text_Wiki
  4180. + */
  4181.  
  4182. /**
  4183. -*
  4184. -* "Pre-filter" the source text.
  4185. -*
  4186. -* Convert DOS and Mac line endings to Unix, concat lines ending in a
  4187. -* backslash \ with the next line, convert tabs to 4-spaces, add newlines
  4188. -* to the top and end of the source text, compress 3 or more newlines to
  4189. -* 2 newlines.
  4190. -*
  4191. -* @category Text
  4192. -*
  4193. -* @package Text_Wiki
  4194. -*
  4195. -* @author Paul M. Jones <pmjones@php.net>
  4196. -*
  4197. -*/
  4198. -
  4199. -class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse {
  4200. -
  4201. -
  4202. + * "Pre-filter" the source text.
  4203. + *
  4204. + * Convert DOS and Mac line endings to Unix, concat lines ending in a
  4205. + * backslash \ with the next line, convert tabs to 4-spaces, add newlines
  4206. + * to the top and end of the source text, compress 3 or more newlines to
  4207. + * 2 newlines.
  4208. + *
  4209. + * @category Text
  4210. + * @package Text_Wiki
  4211. + * @author Paul M. Jones <pmjones@php.net>
  4212. + * @copyright 2005 Paul M. Jones
  4213. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4214. + * @version Release: @package_version@
  4215. + * @link http://pear.php.net/package/Text_Wiki
  4216. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  4217. + */
  4218. +class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse
  4219. +{
  4220. +
  4221. +
  4222. /**
  4223. - *
  4224. - * Simple parsing method.
  4225. - *
  4226. - * @access public
  4227. - *
  4228. - */
  4229. -
  4230. + * Simple parsing method.
  4231. + *
  4232. + * @access public
  4233. + * @return void
  4234. + */
  4235. function parse()
  4236. {
  4237. // convert DOS line endings
  4238. $this->wiki->source = str_replace("\r\n", "\n",
  4239. $this->wiki->source);
  4240. -
  4241. +
  4242. // convert Macintosh line endings
  4243. $this->wiki->source = str_replace("\r", "\n",
  4244. $this->wiki->source);
  4245. -
  4246. +
  4247. // concat lines ending in a backslash
  4248. $this->wiki->source = str_replace("\\\n", "",
  4249. $this->wiki->source);
  4250. -
  4251. +
  4252. // convert tabs to four-spaces
  4253. $this->wiki->source = str_replace("\t", " ",
  4254. $this->wiki->source);
  4255. -
  4256. +
  4257. // add extra newlines at the top and end; this
  4258. // seems to help many rules.
  4259. $this->wiki->source = "\n" . $this->wiki->source . "\n\n";
  4260. -
  4261. +
  4262. // finally, compress all instances of 3 or more newlines
  4263. // down to two newlines.
  4264. - $find = "/\n{3,}/m";
  4265. + $find = "/\n{3,}/m";
  4266. $replace = "\n\n";
  4267. +
  4268. $this->wiki->source = preg_replace($find, $replace,
  4269. $this->wiki->source);
  4270. }
  4271.  
  4272. }
  4273. -?>
  4274. \ No newline at end of file
  4275. +?>
  4276. Index: Text/Wiki/Parse/Cowiki/Raw.php
  4277. ===================================================================
  4278. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Raw.php,v
  4279. retrieving revision 1.1
  4280. diff -u -r1.1 Raw.php
  4281. --- Text/Wiki/Parse/Cowiki/Raw.php 21 Jul 2005 20:56:13 -0000 1.1
  4282. +++ Text/Wiki/Parse/Cowiki/Raw.php 28 Oct 2008 02:23:52 -0000
  4283. @@ -1,72 +1,67 @@
  4284. <?php
  4285.  
  4286. /**
  4287. -*
  4288. -* Parses for text marked as "raw" (i.e., to be rendered as-is).
  4289. -*
  4290. -* @category Text
  4291. -*
  4292. -* @package Text_Wiki
  4293. -*
  4294. -* @author Paul M. Jones <pmjones@php.net>
  4295. -*
  4296. -* @license LGPL
  4297. -*
  4298. -* @version $Id: Raw.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4299. -*
  4300. -*/
  4301. + * Parses for text marked as "raw" (i.e., to be rendered as-is).
  4302. +*
  4303. + * PHP version 4, 5
  4304. + *
  4305. + * @category Text
  4306. + * @package Text_Wiki
  4307. + * @author Paul M. Jones <pmjones@php.net>
  4308. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4309. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4310. + * @link http://pear.php.net/package/Text_Wiki
  4311. + */
  4312.  
  4313. /**
  4314. -*
  4315. -* Parses for text marked as "raw" (i.e., to be rendered as-is).
  4316. -*
  4317. + * Parses for text marked as "raw" (i.e., to be rendered as-is).
  4318. +*
  4319. * This class implements a Text_Wiki rule to find sections of the source
  4320. * text that are not to be processed by Text_Wiki. These blocks of "raw"
  4321. * text will be rendered as they were found.
  4322. *
  4323. -* @category Text
  4324. -*
  4325. -* @package Text_Wiki
  4326. -*
  4327. -* @author Paul M. Jones <pmjones@php.net>
  4328. -*
  4329. -*/
  4330. -
  4331. -class Text_Wiki_Parse_Raw extends Text_Wiki_Parse {
  4332. -
  4333. -
  4334. + * @category Text
  4335. + * @package Text_Wiki
  4336. + * @author Paul M. Jones <pmjones@php.net>
  4337. + * @copyright 2005 Paul M. Jones
  4338. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4339. + * @version Release: @package_version@
  4340. + * @link http://pear.php.net/package/Text_Wiki
  4341. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  4342. + */
  4343. +
  4344. +class Text_Wiki_Parse_Raw extends Text_Wiki_Parse
  4345. +{
  4346. +
  4347. +
  4348. /**
  4349. - *
  4350. - * The regular expression used to find source text matching this
  4351. - * rule.
  4352. - *
  4353. - * @access public
  4354. - *
  4355. - * @var string
  4356. - *
  4357. - */
  4358. -
  4359. + * The regular expression used to find source text matching this
  4360. + * rule.
  4361. + *
  4362. + * @access public
  4363. + *
  4364. + * @var string
  4365. + *
  4366. + */
  4367. +
  4368. var $regex = '/<noop>(.*)<\/noop>/U';
  4369.  
  4370. /**
  4371. - *
  4372. - * Generates a token entry for the matched text. Token options are:
  4373. - *
  4374. - * 'text' => The full matched text.
  4375. - *
  4376. - * @access public
  4377. - *
  4378. - * @param array &$matches The array of matches from parse().
  4379. - *
  4380. - * @return A delimited token number to be used as a placeholder in
  4381. - * the source text.
  4382. - *
  4383. - */
  4384. -
  4385. + * Generates a token entry for the matched text. Token options are:
  4386. + *
  4387. + * 'text' => The full matched text.
  4388. + *
  4389. + * @param array &$matches The array of matches from parse().
  4390. + *
  4391. + * @access public
  4392. + * @return A delimited token number to be used as a placeholder in
  4393. + * the source text.
  4394. + */
  4395. +
  4396. function process(&$matches)
  4397. {
  4398. $options = array('text' => strlen($matches[1]) ? $matches[1] : $matches[2]);
  4399. return $this->wiki->addToken($this->rule, $options);
  4400. }
  4401. }
  4402. -?>
  4403. \ No newline at end of file
  4404. +?>
  4405. Index: Text/Wiki/Parse/Cowiki/Revise.php
  4406. ===================================================================
  4407. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Revise.php,v
  4408. retrieving revision 1.1
  4409. diff -u -r1.1 Revise.php
  4410. --- Text/Wiki/Parse/Cowiki/Revise.php 21 Jul 2005 20:56:13 -0000 1.1
  4411. +++ Text/Wiki/Parse/Cowiki/Revise.php 28 Oct 2008 02:23:52 -0000
  4412. @@ -1,131 +1,126 @@
  4413. <?php
  4414.  
  4415. /**
  4416. -*
  4417. -* Parses for text marked as revised (insert/delete).
  4418. -*
  4419. -* @category Text
  4420. -*
  4421. -* @package Text_Wiki
  4422. -*
  4423. -* @author Paul M. Jones <pmjones@php.net>
  4424. -*
  4425. -* @license LGPL
  4426. -*
  4427. -* @version $Id: Revise.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4428. -*
  4429. -*/
  4430. + * Parses for text marked as revised (insert/delete).
  4431. +*
  4432. + * PHP version 4, 5
  4433. + *
  4434. + * @category Text
  4435. + * @package Text_Wiki
  4436. + * @author Paul M. Jones <pmjones@php.net>
  4437. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4438. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4439. + * @link http://pear.php.net/package/Text_Wiki
  4440. + */
  4441.  
  4442. /**
  4443. -*
  4444. -* Parses for text marked as revised (insert/delete).
  4445. -*
  4446. -* @category Text
  4447. -*
  4448. -* @package Text_Wiki
  4449. -*
  4450. -* @author Paul M. Jones <pmjones@php.net>
  4451. -*
  4452. -*/
  4453. -//Not used in CoWiki
  4454. -//Added strikethrough :-)
  4455. -class Text_Wiki_Parse_Revise extends Text_Wiki_Parse {
  4456. -
  4457. -
  4458. + * Parses for text marked as revised (insert/delete).
  4459. + *
  4460. + * @category Text
  4461. + * @package Text_Wiki
  4462. + * @author Paul M. Jones <pmjones@php.net>
  4463. + * @copyright 2005 Paul M. Jones
  4464. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4465. + * @version Release: @package_version@
  4466. + * @link http://pear.php.net/package/Text_Wiki
  4467. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  4468. + */
  4469. +class Text_Wiki_Parse_Revise extends Text_Wiki_Parse
  4470. +{
  4471. +
  4472. +
  4473. /**
  4474. - *
  4475. - * The regular expression used to parse the source text and find
  4476. - * matches conforming to this rule. Used by the parse() method.
  4477. - *
  4478. - * @access public
  4479. - *
  4480. - * @var string
  4481. - *
  4482. - * @see parse()
  4483. - *
  4484. - */
  4485. -
  4486. + * The regular expression used to parse the source text and find
  4487. + * matches conforming to this rule. Used by the parse() method.
  4488. + *
  4489. + * @access public
  4490. + * @var string
  4491. + * @see parse()
  4492. + */
  4493. var $regex = "/\@\@({*?.*}*?)\@\@/U";
  4494. -
  4495. -
  4496. +
  4497. +
  4498. /**
  4499. - *
  4500. - * Config options.
  4501. - *
  4502. - * @access public
  4503. - *
  4504. - * @var array
  4505. - *
  4506. - */
  4507. -
  4508. + * Config options.
  4509. + *
  4510. + * @access public
  4511. + * @var array
  4512. + */
  4513. +
  4514. var $conf = array(
  4515. 'delmark' => '---',
  4516. 'insmark' => '+++'
  4517. );
  4518.  
  4519.  
  4520. + /**
  4521. + * Parse.
  4522. + *
  4523. + * @return void
  4524. + */
  4525. function parse()
  4526. {
  4527. - $this->wiki->source = preg_replace_callback(
  4528. - $this->regex,
  4529. + $this->wiki->source = preg_replace_callback($this->regex,
  4530. array(&$this, 'process'),
  4531. - $this->wiki->source
  4532. - );
  4533. -
  4534. + $this->wiki->source);
  4535. +
  4536. $tmp_regex = '!-(.*?)-!';
  4537. - $this->wiki->source = preg_replace_callback(
  4538. - $tmp_regex,
  4539. +
  4540. + $this->wiki->source = preg_replace_callback($tmp_regex,
  4541. array(&$this, 'processDel'),
  4542. - $this->wiki->source
  4543. - );
  4544. + $this->wiki->source);
  4545.  
  4546. - }
  4547. + }
  4548.  
  4549. - function processDel($matches) {
  4550. + /**
  4551. + * ProcessDel
  4552. + *
  4553. + * @param string[] $matches Matches
  4554. + *
  4555. + * @return object
  4556. + */
  4557. + function processDel($matches)
  4558. + {
  4559. return $this->wiki->addToken($this->rule, array('type' => 'del_start')).
  4560. $matches[1].
  4561. $this->wiki->addToken($this->rule, array('type' => 'del_end'));
  4562. }
  4563. -
  4564. -
  4565. +
  4566. +
  4567. /**
  4568. - *
  4569. - * Generates a replacement for the matched text. Token options are:
  4570. - *
  4571. - * 'type' => ['start'|'end'] The starting or ending point of the
  4572. - * inserted text. The text itself is left in the source.
  4573. - *
  4574. - * @access public
  4575. - *
  4576. - * @param array &$matches The array of matches from parse().
  4577. - *
  4578. - * @return string A pair of delimited tokens to be used as a
  4579. - * placeholder in the source text surrounding the teletype text.
  4580. - *
  4581. - */
  4582. -
  4583. + * Generates a replacement for the matched text. Token options are:
  4584. + * 'type' => ['start'|'end'] The starting or ending point of the
  4585. + * inserted text. The text itself is left in the source.
  4586. + *
  4587. + * @param array &$matches The array of matches from parse().
  4588. + *
  4589. + * @access public
  4590. + * @return string A pair of delimited tokens to be used as a
  4591. + * placeholder in the source text surrounding the teletype text.
  4592. + */
  4593. function process(&$matches)
  4594. {
  4595. $output = '';
  4596. - $src = $matches[1];
  4597. + $src = $matches[1];
  4598. +
  4599. $delmark = $this->getConf('delmark'); // ---
  4600. $insmark = $this->getConf('insmark'); // +++
  4601. -
  4602. +
  4603. // '---' must be before '+++' (if they both appear)
  4604. $del = strpos($src, $delmark);
  4605. $ins = strpos($src, $insmark);
  4606. -
  4607. +
  4608. // if neither is found, return right away
  4609. if ($del === false && $ins === false) {
  4610. return $matches[0];
  4611. }
  4612. -
  4613. +
  4614. // handle text to be deleted
  4615. if ($del !== false) {
  4616. -
  4617. +
  4618. // move forward to the end of the deletion mark
  4619. $del += strlen($delmark);
  4620. -
  4621. +
  4622. if ($ins === false) {
  4623. // there is no insertion text following
  4624. $text = substr($src, $del);
  4625. @@ -134,37 +129,33 @@
  4626. // mitigate the length
  4627. $text = substr($src, $del, $ins - $del);
  4628. }
  4629. -
  4630. - $output .= $this->wiki->addToken(
  4631. - $this->rule, array('type' => 'del_start')
  4632. - );
  4633. -
  4634. +
  4635. + $output .= $this->wiki->addToken($this->rule,
  4636. + array('type' => 'del_start'));
  4637. +
  4638. $output .= $text;
  4639. -
  4640. - $output .= $this->wiki->addToken(
  4641. - $this->rule, array('type' => 'del_end')
  4642. - );
  4643. +
  4644. + $output .= $this->wiki->addToken($this->rule,
  4645. + array('type' => 'del_end'));
  4646. }
  4647. -
  4648. +
  4649. // handle text to be inserted
  4650. if ($ins !== false) {
  4651. -
  4652. +
  4653. // move forward to the end of the insert mark
  4654. $ins += strlen($insmark);
  4655. $text = substr($src, $ins);
  4656. -
  4657. - $output .= $this->wiki->addToken(
  4658. - $this->rule, array('type' => 'ins_start')
  4659. - );
  4660. -
  4661. +
  4662. + $output .= $this->wiki->addToken($this->rule,
  4663. + array('type' => 'ins_start'));
  4664. +
  4665. $output .= $text;
  4666. -
  4667. - $output .= $this->wiki->addToken(
  4668. - $this->rule, array('type' => 'ins_end')
  4669. - );
  4670. +
  4671. + $output .= $this->wiki->addToken($this->rule,
  4672. + array('type' => 'ins_end'));
  4673. }
  4674. -
  4675. +
  4676. return $output;
  4677. }
  4678. }
  4679. -?>
  4680. \ No newline at end of file
  4681. +?>
  4682. Index: Text/Wiki/Parse/Cowiki/Strong.php
  4683. ===================================================================
  4684. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Strong.php,v
  4685. retrieving revision 1.1
  4686. diff -u -r1.1 Strong.php
  4687. --- Text/Wiki/Parse/Cowiki/Strong.php 21 Jul 2005 20:56:13 -0000 1.1
  4688. +++ Text/Wiki/Parse/Cowiki/Strong.php 28 Oct 2008 02:23:52 -0000
  4689. @@ -1,85 +1,75 @@
  4690. <?php
  4691.  
  4692. /**
  4693. -*
  4694. -* Parses for strongly-emphasized text.
  4695. -*
  4696. -* @category Text
  4697. -*
  4698. -* @package Text_Wiki
  4699. -*
  4700. -* @author Paul M. Jones <pmjones@php.net>
  4701. -*
  4702. -* @license LGPL
  4703. -*
  4704. -* @version $Id: Strong.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4705. -*
  4706. -*/
  4707. + * Parses for strongly-emphasized text.
  4708. +*
  4709. + * PHP version 4, 5
  4710. + *
  4711. + * @category Text
  4712. + * @package Text_Wiki
  4713. + * @author Paul M. Jones <pmjones@php.net>
  4714. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4715. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4716. + * @link http://pear.php.net/package/Text_Wiki
  4717. + */
  4718.  
  4719.  
  4720. /**
  4721. -*
  4722. -* Parses for strongly-emphasized text.
  4723. -*
  4724. -* This class implements a Text_Wiki_Parse to find source text marked for
  4725. -* strong emphasis (bold) as defined by text surrounded by three
  4726. -* single-quotes. On parsing, the text itself is left in place, but the
  4727. -* starting and ending instances of three single-quotes are replaced with
  4728. -* tokens.
  4729. -*
  4730. -* @category Text
  4731. -*
  4732. -* @package Text_Wiki
  4733. -*
  4734. -* @author Paul M. Jones <pmjones@php.net>
  4735. -*
  4736. -*/
  4737. -
  4738. -class Text_Wiki_Parse_Strong extends Text_Wiki_Parse {
  4739. -
  4740. -
  4741. + * Parses for strongly-emphasized text.
  4742. + *
  4743. + * This class implements a Text_Wiki_Parse to find source text marked for
  4744. + * strong emphasis (bold) as defined by text surrounded by three
  4745. + * single-quotes. On parsing, the text itself is left in place, but the
  4746. + * starting and ending instances of three single-quotes are replaced with
  4747. + * tokens.
  4748. + *
  4749. + * @category Text
  4750. + * @package Text_Wiki
  4751. + * @author Paul M. Jones <pmjones@php.net>
  4752. + * @copyright 2005 Paul M. Jones
  4753. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4754. + * @version Release: @package_version@
  4755. + * @link http://pear.php.net/package/Text_Wiki
  4756. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  4757. + */
  4758. +
  4759. +class Text_Wiki_Parse_Strong extends Text_Wiki_Parse
  4760. +{
  4761. +
  4762. +
  4763. /**
  4764. - *
  4765. - * The regular expression used to parse the source text and find
  4766. - * matches conforming to this rule. Used by the parse() method.
  4767. - *
  4768. - * @access public
  4769. - *
  4770. - * @var string
  4771. - *
  4772. - * @see parse()
  4773. - *
  4774. - */
  4775. -
  4776. + * The regular expression used to parse the source text and find
  4777. + * matches conforming to this rule. Used by the parse() method.
  4778. + *
  4779. + * @access public
  4780. + *
  4781. + * @var string
  4782. + *
  4783. + * @see parse()
  4784. + *
  4785. + */
  4786. +
  4787. var $regex = '/\*(.*?)\*/';
  4788. -
  4789. +
  4790. /**
  4791. - *
  4792. - * Generates a replacement for the matched text. Token options are:
  4793. - *
  4794. - * 'type' => ['start'|'end'] The starting or ending point of the
  4795. - * emphasized text. The text itself is left in the source.
  4796. - *
  4797. - * @access public
  4798. - *
  4799. - * @param array &$matches The array of matches from parse().
  4800. - *
  4801. - * @return A pair of delimited tokens to be used as a placeholder in
  4802. - * the source text surrounding the text to be emphasized.
  4803. - *
  4804. - */
  4805. -
  4806. + * Generates a replacement for the matched text. Token options are:
  4807. + *
  4808. + * 'type' => ['start'|'end'] The starting or ending point of the
  4809. + * emphasized text. The text itself is left in the source.
  4810. + *
  4811. + * @param array &$matches The array of matches from parse().
  4812. + *
  4813. + * @access public
  4814. + * @return A pair of delimited tokens to be used as a placeholder in
  4815. + * the source text surrounding the text to be emphasized.
  4816. + *
  4817. + */
  4818. function process(&$matches)
  4819. {
  4820. - $start = $this->wiki->addToken(
  4821. - $this->rule, array('type' => 'start')
  4822. - );
  4823. -
  4824. - $end = $this->wiki->addToken(
  4825. - $this->rule, array('type' => 'end')
  4826. - );
  4827. -
  4828. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  4829. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  4830. +
  4831. return $start . $matches[1] . $end;
  4832. }
  4833. }
  4834. -?>
  4835. \ No newline at end of file
  4836. +?>
  4837. Index: Text/Wiki/Parse/Cowiki/Subscript.php
  4838. ===================================================================
  4839. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Subscript.php,v
  4840. retrieving revision 1.1
  4841. diff -u -r1.1 Subscript.php
  4842. --- Text/Wiki/Parse/Cowiki/Subscript.php 21 Jul 2005 20:56:13 -0000 1.1
  4843. +++ Text/Wiki/Parse/Cowiki/Subscript.php 28 Oct 2008 02:23:52 -0000
  4844. @@ -1,79 +1,64 @@
  4845. <?php
  4846. -
  4847. /**
  4848. -*
  4849. -* Parses for subscripted text.
  4850. -*
  4851. -* @category Text
  4852. -*
  4853. -* @package Text_Wiki
  4854. -*
  4855. -* @author Paul M. Jones <pmjones@php.net>
  4856. -*
  4857. -* @license LGPL
  4858. -*
  4859. -* @version $Id: Subscript.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4860. -*
  4861. -*/
  4862. + * Parses for subscripted text.
  4863. + *
  4864. + * PHP version 4, 5
  4865. + *
  4866. + * @category Text
  4867. + * @package Text_Wiki
  4868. + * @author Paul M. Jones <pmjones@php.net>
  4869. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4870. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  4871. + * @link http://pear.php.net/package/Text_Wiki
  4872. + */
  4873.  
  4874. /**
  4875. -*
  4876. -* Parses for subscripted text.
  4877. -*
  4878. -* @category Text
  4879. -*
  4880. -* @package Text_Wiki
  4881. -*
  4882. -* @author Paul M. Jones <pmjones@php.net>
  4883. -*
  4884. -*/
  4885. -
  4886. -class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse {
  4887. -
  4888. -
  4889. + * Parses for subscripted text.
  4890. + *
  4891. + * @category Text
  4892. + * @package Text_Wiki
  4893. + * @author Paul M. Jones <pmjones@php.net>
  4894. + * @copyright 2005 Paul M. Jones
  4895. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  4896. + * @version Release: @package_version@
  4897. + * @link http://pear.php.net/package/Text_Wiki
  4898. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  4899. + */
  4900. +class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse
  4901. +{
  4902. +
  4903. /**
  4904. - *
  4905. - * The regular expression used to parse the source text and find
  4906. - * matches conforming to this rule. Used by the parse() method.
  4907. - *
  4908. - * @access public
  4909. - *
  4910. - * @var string
  4911. - *
  4912. - * @see parse()
  4913. - *
  4914. - */
  4915. -
  4916. + * The regular expression used to parse the source text and find
  4917. + * matches conforming to this rule. Used by the parse() method.
  4918. + *
  4919. + * @access public
  4920. + *
  4921. + * @var string
  4922. + *
  4923. + * @see parse()
  4924. + */
  4925. var $regex = '/<sub>(()|.*)<\/sub>/U';
  4926. -
  4927. -
  4928. +
  4929. +
  4930. /**
  4931. - *
  4932. - * Generates a replacement for the matched text. Token options are:
  4933. - *
  4934. - * 'type' => ['start'|'end'] The starting or ending point of the
  4935. - * emphasized text. The text itself is left in the source.
  4936. - *
  4937. - * @access public
  4938. - *
  4939. - * @param array &$matches The array of matches from parse().
  4940. - *
  4941. - * @return A pair of delimited tokens to be used as a placeholder in
  4942. - * the source text surrounding the text to be emphasized.
  4943. - *
  4944. - */
  4945. -
  4946. + * Generates a replacement for the matched text. Token options are:
  4947. + *
  4948. + * 'type' => ['start'|'end'] The starting or ending point of the
  4949. + * emphasized text. The text itself is left in the source.
  4950. + *
  4951. + * @param array &$matches The array of matches from parse().
  4952. + *
  4953. + * @access public
  4954. + * @return A pair of delimited tokens to be used as a placeholder in
  4955. + * the source text surrounding the text to be emphasized.
  4956. + */
  4957. function process(&$matches)
  4958. {
  4959. - $start = $this->wiki->addToken(
  4960. - $this->rule, array('type' => 'start')
  4961. - );
  4962. -
  4963. - $end = $this->wiki->addToken(
  4964. - $this->rule, array('type' => 'end')
  4965. - );
  4966. -
  4967. +
  4968. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  4969. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  4970. +
  4971. return $start . $matches[1] . $end;
  4972. }
  4973. }
  4974. -?>
  4975. \ No newline at end of file
  4976. +?>
  4977. Index: Text/Wiki/Parse/Cowiki/Superscript.php
  4978. ===================================================================
  4979. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Superscript.php,v
  4980. retrieving revision 1.1
  4981. diff -u -r1.1 Superscript.php
  4982. --- Text/Wiki/Parse/Cowiki/Superscript.php 21 Jul 2005 20:56:13 -0000 1.1
  4983. +++ Text/Wiki/Parse/Cowiki/Superscript.php 28 Oct 2008 02:23:52 -0000
  4984. @@ -1,79 +1,70 @@
  4985. <?php
  4986.  
  4987. /**
  4988. -*
  4989. -* Parses for superscripted text.
  4990. -*
  4991. -* @category Text
  4992. -*
  4993. -* @package Text_Wiki
  4994. -*
  4995. -* @author Paul M. Jones <pmjones@php.net>
  4996. -*
  4997. -* @license LGPL
  4998. -*
  4999. -* @version $Id: Superscript.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5000. -*
  5001. -*/
  5002. + * Parses for superscripted text.
  5003. +*
  5004. + * PHP version 4, 5
  5005. + *
  5006. + * @category Text
  5007. + * @package Text_Wiki
  5008. + * @author Paul M. Jones <pmjones@php.net>
  5009. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5010. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5011. + * @link http://pear.php.net/package/Text_Wiki
  5012. + */
  5013.  
  5014. /**
  5015. -*
  5016. -* Parses for superscripted text.
  5017. -*
  5018. -* @category Text
  5019. -*
  5020. -* @package Text_Wiki
  5021. -*
  5022. -* @author Paul M. Jones <pmjones@php.net>
  5023. -*
  5024. -*/
  5025. -
  5026. -class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse {
  5027. -
  5028. -
  5029. + * Parses for superscripted text.
  5030. +*
  5031. + * @category Text
  5032. + * @package Text_Wiki
  5033. + * @author Paul M. Jones <pmjones@php.net>
  5034. + * @copyright 2005 Paul M. Jones
  5035. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5036. + * @version Release: @package_version@
  5037. + * @link http://pear.php.net/package/Text_Wiki
  5038. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  5039. + */
  5040. +
  5041. +class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse
  5042. +{
  5043. +
  5044. +
  5045. /**
  5046. - *
  5047. - * The regular expression used to parse the source text and find
  5048. - * matches conforming to this rule. Used by the parse() method.
  5049. - *
  5050. - * @access public
  5051. - *
  5052. - * @var string
  5053. - *
  5054. - * @see parse()
  5055. - *
  5056. - */
  5057. -
  5058. + * The regular expression used to parse the source text and find
  5059. + * matches conforming to this rule. Used by the parse() method.
  5060. + *
  5061. + * @access public
  5062. + *
  5063. + * @var string
  5064. + *
  5065. + * @see parse()
  5066. + *
  5067. + */
  5068. +
  5069. var $regex = '/<sup>(()|.*)<\/sup>/U';
  5070. -
  5071. -
  5072. +
  5073. +
  5074. /**
  5075. - *
  5076. - * Generates a replacement for the matched text. Token options are:
  5077. - *
  5078. - * 'type' => ['start'|'end'] The starting or ending point of the
  5079. - * emphasized text. The text itself is left in the source.
  5080. - *
  5081. - * @access public
  5082. - *
  5083. - * @param array &$matches The array of matches from parse().
  5084. - *
  5085. - * @return A pair of delimited tokens to be used as a placeholder in
  5086. - * the source text surrounding the text to be emphasized.
  5087. - *
  5088. - */
  5089. -
  5090. + * Generates a replacement for the matched text. Token options are:
  5091. + *
  5092. + * 'type' => ['start'|'end'] The starting or ending point of the
  5093. + * emphasized text. The text itself is left in the source.
  5094. + *
  5095. + * @param array &$matches The array of matches from parse().
  5096. + *
  5097. + * @access public
  5098. + * @return A pair of delimited tokens to be used as a placeholder in
  5099. + * the source text surrounding the text to be emphasized.
  5100. + *
  5101. + */
  5102. +
  5103. function process(&$matches)
  5104. {
  5105. - $start = $this->wiki->addToken(
  5106. - $this->rule, array('type' => 'start')
  5107. - );
  5108. -
  5109. - $end = $this->wiki->addToken(
  5110. - $this->rule, array('type' => 'end')
  5111. - );
  5112. -
  5113. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  5114. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  5115. +
  5116. return $start . $matches[1] . $end;
  5117. }
  5118. }
  5119. -?>
  5120. \ No newline at end of file
  5121. +?>
  5122. Index: Text/Wiki/Parse/Cowiki/Table.php
  5123. ===================================================================
  5124. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Table.php,v
  5125. retrieving revision 1.1
  5126. diff -u -r1.1 Table.php
  5127. --- Text/Wiki/Parse/Cowiki/Table.php 21 Jul 2005 20:56:13 -0000 1.1
  5128. +++ Text/Wiki/Parse/Cowiki/Table.php 28 Oct 2008 02:23:52 -0000
  5129. @@ -1,89 +1,82 @@
  5130. <?php
  5131. -
  5132. /**
  5133. -*
  5134. -* Parses for table markup.
  5135. -*
  5136. -* @category Text
  5137. -*
  5138. -* @package Text_Wiki
  5139. -*
  5140. -* @author Paul M. Jones <pmjones@php.net>
  5141. -*
  5142. -* @license LGPL
  5143. -*
  5144. -* @version $Id: Table.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5145. -*
  5146. -*/
  5147. + * Parses for table markup.
  5148. + *
  5149. + * PHP version 4, 5
  5150. + *
  5151. + * @category Text
  5152. + * @package Text_Wiki
  5153. + * @author Paul M. Jones <pmjones@php.net>
  5154. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5155. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5156. + * @link http://pear.php.net/package/Text_Wiki
  5157. + */
  5158.  
  5159. /**
  5160. -*
  5161. -* Parses for table markup.
  5162. -*
  5163. -* This class implements a Text_Wiki_Parse to find source text marked as a
  5164. -* set of table rows, where a line start and ends with double-pipes (||)
  5165. -* and uses double-pipes to separate table cells. The rows must be on
  5166. -* sequential lines (no blank lines between them) -- a blank line
  5167. -* indicates the beginning of a new table.
  5168. -*
  5169. -* @category Text
  5170. -*
  5171. -* @package Text_Wiki
  5172. -*
  5173. -* @author Paul M. Jones <pmjones@php.net>
  5174. -*
  5175. -*/
  5176. -
  5177. -class Text_Wiki_Parse_Table extends Text_Wiki_Parse {
  5178. -
  5179. -
  5180. + * Parses for table markup.
  5181. + *
  5182. + * This class implements a Text_Wiki_Parse to find source text marked as a
  5183. + * set of table rows, where a line start and ends with double-pipes (||)
  5184. + * and uses double-pipes to separate table cells. The rows must be on
  5185. + * sequential lines (no blank lines between them) -- a blank line
  5186. + * indicates the beginning of a new table.
  5187. + *
  5188. + * @category Text
  5189. + * @package Text_Wiki
  5190. + * @author Paul M. Jones <pmjones@php.net>
  5191. + * @copyright 2005 Paul M. Jones
  5192. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5193. + * @version Release: @package_version@
  5194. + * @link http://pear.php.net/package/Text_Wiki
  5195. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  5196. + */
  5197. +
  5198. +class Text_Wiki_Parse_Table extends Text_Wiki_Parse
  5199. +{
  5200. +
  5201. +
  5202. /**
  5203. - *
  5204. - * The regular expression used to parse the source text and find
  5205. - * matches conforming to this rule. Used by the parse() method.
  5206. - *
  5207. - * @access public
  5208. - *
  5209. - * @var string
  5210. - *
  5211. - * @see parse()
  5212. - *
  5213. - */
  5214. -
  5215. + * The regular expression used to parse the source text and find
  5216. + * matches conforming to this rule. Used by the parse() method.
  5217. + *
  5218. + * @access public
  5219. + *
  5220. + * @var string
  5221. + *
  5222. + * @see parse()
  5223. + *
  5224. + */
  5225. +
  5226. var $regex = '/\n<table( [^>]*)?>(.*?)<\/table>\n/Us';
  5227. -
  5228. -
  5229. +
  5230. +
  5231. /**
  5232. - *
  5233. - * Generates a replacement for the matched text.
  5234. - *
  5235. - * Token options are:
  5236. - *
  5237. - * 'type' =>
  5238. - * 'table_start' : the start of a bullet list
  5239. - * 'table_end' : the end of a bullet list
  5240. - * 'row_start' : the start of a number list
  5241. - * 'row_end' : the end of a number list
  5242. - * 'cell_start' : the start of item text (bullet or number)
  5243. - * 'cell_end' : the end of item text (bullet or number)
  5244. - *
  5245. - * 'cols' => the number of columns in the table (for 'table_start')
  5246. - *
  5247. - * 'rows' => the number of rows in the table (for 'table_start')
  5248. - *
  5249. - * 'span' => column span (for 'cell_start')
  5250. - *
  5251. - * 'attr' => column attribute flag (for 'cell_start')
  5252. - *
  5253. - * @access public
  5254. - *
  5255. - * @param array &$matches The array of matches from parse().
  5256. - *
  5257. - * @return A series of text and delimited tokens marking the different
  5258. - * table elements and cell text.
  5259. - *
  5260. - */
  5261. -
  5262. + * Generates a replacement for the matched text.
  5263. + *
  5264. + * Token options are:
  5265. + *
  5266. + * 'type' =>
  5267. + * 'table_start' : the start of a bullet list
  5268. + * 'table_end' : the end of a bullet list
  5269. + * 'row_start' : the start of a number list
  5270. + * 'row_end' : the end of a number list
  5271. + * 'cell_start' : the start of item text (bullet or number)
  5272. + * 'cell_end' : the end of item text (bullet or number)
  5273. + *
  5274. + * 'cols' => the number of columns in the table (for 'table_start')
  5275. + *
  5276. + * 'rows' => the number of rows in the table (for 'table_start')
  5277. + *
  5278. + * 'span' => column span (for 'cell_start')
  5279. + *
  5280. + * 'attr' => column attribute flag (for 'cell_start')
  5281. + *
  5282. + * @param array &$matches The array of matches from parse().
  5283. + *
  5284. + * @access public
  5285. + * @return A series of text and delimited tokens marking the different
  5286. + * table elements and cell text.
  5287. + */
  5288. function process(&$matches)
  5289. {
  5290. if (strlen(trim($matches[1]))) {
  5291. @@ -94,121 +87,102 @@
  5292.  
  5293. // our eventual return value
  5294. $return = '';
  5295. -
  5296. +
  5297. // the number of columns in the table
  5298. $num_cols = 0;
  5299. -
  5300. +
  5301. // the number of rows in the table
  5302. $num_rows = 0;
  5303. -
  5304. +
  5305. // rows are separated by newlines in the matched text
  5306. $rows = explode("\n", $matches[2]);
  5307. -
  5308. +
  5309. // loop through each row
  5310. foreach ($rows as $row) {
  5311. if (!strlen($row)) {
  5312. continue;
  5313. }
  5314. -
  5315. +
  5316. // increase the row count
  5317. ++$num_rows;
  5318. -
  5319. +
  5320. // start a new row
  5321. - $return .= $this->wiki->addToken(
  5322. - $this->rule,
  5323. - array('type' => 'row_start')
  5324. - );
  5325. -
  5326. + $return .= $this->wiki->addToken($this->rule,
  5327. + array('type' => 'row_start'));
  5328. +
  5329. // cells are separated by pipes
  5330. $cells = explode('|', $row);
  5331. -
  5332. +
  5333. // get the number of cells (columns) in this row
  5334. $last = count($cells);
  5335. -
  5336. +
  5337. // is this more than the current column count?
  5338. if ($last - 1 > $num_cols) {
  5339. // increase the column count
  5340. $num_cols = $last - 1;
  5341. }
  5342. -
  5343. +
  5344. // by default, cells span only one column (their own)
  5345. $span = 1;
  5346. -
  5347. +
  5348. for ($i = 1; $i < $last; ++$i) {
  5349. -
  5350. +
  5351. // if there is no content at all, then it's an instance
  5352. // of two sets of || next to each other, indicating a
  5353. // span.
  5354. if ($cells[$i] == '') {
  5355. -
  5356. +
  5357. // add to the span and loop to the next cell
  5358. $span += 1;
  5359. continue;
  5360. -
  5361. +
  5362. } else {
  5363. -
  5364. +
  5365. // this cell has content.
  5366.  
  5367. - $attr = null;
  5368. -
  5369. + $attr = null;
  5370. +
  5371. // start a new cell...
  5372. - $return .= $this->wiki->addToken(
  5373. - $this->rule,
  5374. - array (
  5375. - 'type' => 'cell_start',
  5376. - 'attr' => $attr,
  5377. - 'span' => $span
  5378. - )
  5379. - );
  5380. -
  5381. + $return .= $this->wiki->addToken($this->rule,
  5382. + array('type' => 'cell_start',
  5383. + 'attr' => $attr,
  5384. + 'span' => $span));
  5385. +
  5386. // ...add the content...
  5387. $return .= trim($cells[$i]);
  5388. -
  5389. +
  5390. // ...and end the cell.
  5391. - $return .= $this->wiki->addToken(
  5392. - $this->rule,
  5393. - array (
  5394. - 'type' => 'cell_end',
  5395. - 'attr' => $attr,
  5396. - 'span' => $span
  5397. - )
  5398. - );
  5399. -
  5400. + $return .= $this->wiki->addToken($this->rule,
  5401. + array (
  5402. + 'type' => 'cell_end',
  5403. + 'attr' => $attr,
  5404. + 'span' => $span));
  5405. +
  5406. // reset the span.
  5407. $span = 1;
  5408. }
  5409. -
  5410. +
  5411. }
  5412. -
  5413. +
  5414. // end the row
  5415. - $return .= $this->wiki->addToken(
  5416. - $this->rule,
  5417. - array('type' => 'row_end')
  5418. - );
  5419. -
  5420. + $return .= $this->wiki->addToken($this->rule,
  5421. + array('type' => 'row_end'));
  5422. +
  5423. }
  5424. -
  5425. - // wrap the return value in start and end tokens
  5426. +
  5427. + // wrap the return value in start and end tokens
  5428. $return =
  5429. - $this->wiki->addToken(
  5430. - $this->rule,
  5431. - array(
  5432. - 'type' => 'table_start',
  5433. - 'rows' => $num_rows,
  5434. - 'cols' => $num_cols,
  5435. - 'attr' => $attr
  5436. - )
  5437. - )
  5438. + $this->wiki->addToken($this->rule,
  5439. + array('type' => 'table_start',
  5440. + 'rows' => $num_rows,
  5441. + 'cols' => $num_cols,
  5442. + 'attr' => $attr))
  5443. . $return .
  5444. - $this->wiki->addToken(
  5445. - $this->rule,
  5446. - array(
  5447. - 'type' => 'table_end'
  5448. - )
  5449. - );
  5450. -
  5451. + $this->wiki->addToken($this->rule,
  5452. + array('type' => 'table_end'));
  5453. +
  5454. // we're done!
  5455. return "\n$return\n\n";
  5456. }
  5457. }
  5458. -?>
  5459. \ No newline at end of file
  5460. +?>
  5461. Index: Text/Wiki/Parse/Cowiki/Tighten.php
  5462. ===================================================================
  5463. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Tighten.php,v
  5464. retrieving revision 1.1
  5465. diff -u -r1.1 Tighten.php
  5466. --- Text/Wiki/Parse/Cowiki/Tighten.php 21 Jul 2005 20:56:13 -0000 1.1
  5467. +++ Text/Wiki/Parse/Cowiki/Tighten.php 28 Oct 2008 02:23:52 -0000
  5468. @@ -1,49 +1,44 @@
  5469. <?php
  5470. -
  5471. /**
  5472. -*
  5473. -* The rule removes all remaining newlines.
  5474. -*
  5475. -* @category Text
  5476. -*
  5477. -* @package Text_Wiki
  5478. -*
  5479. -* @author Paul M. Jones <pmjones@php.net>
  5480. -*
  5481. -* @license LGPL
  5482. -*
  5483. -* @version $Id: Tighten.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5484. -*
  5485. -*/
  5486. + * The rule removes all remaining newlines.
  5487. + *
  5488. + * PHP version 4, 5
  5489. + *
  5490. + * @category Text
  5491. + * @package Text_Wiki
  5492. + * @author Paul M. Jones <pmjones@php.net>
  5493. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5494. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5495. + * @link http://pear.php.net/package/Text_Wiki
  5496. + */
  5497.  
  5498.  
  5499. /**
  5500. -*
  5501. -* The rule removes all remaining newlines.
  5502. -*
  5503. -* @category Text
  5504. -*
  5505. -* @package Text_Wiki
  5506. -*
  5507. -* @author Paul M. Jones <pmjones@php.net>
  5508. -*
  5509. -*/
  5510. + * The rule removes all remaining newlines.
  5511. + *
  5512. + * @category Text
  5513. + * @package Text_Wiki
  5514. + * @author Paul M. Jones <pmjones@php.net>
  5515. + * @copyright 2005 Paul M. Jones
  5516. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5517. + * @version Release: @package_version@
  5518. + * @link http://pear.php.net/package/Text_Wiki
  5519. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  5520. + */
  5521. +class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse
  5522. +{
  5523. +
  5524.  
  5525. -class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse {
  5526. -
  5527. -
  5528. /**
  5529. - *
  5530. - * Apply tightening directly to the source text.
  5531. - *
  5532. - * @access public
  5533. - *
  5534. - */
  5535. -
  5536. + * Apply tightening directly to the source text.
  5537. + *
  5538. + * @access public
  5539. + * @return void
  5540. + */
  5541. function parse()
  5542. {
  5543. $this->wiki->source = str_replace("\n", '',
  5544. $this->wiki->source);
  5545. }
  5546. }
  5547. -?>
  5548. \ No newline at end of file
  5549. +?>
  5550. Index: Text/Wiki/Parse/Cowiki/Toc.php
  5551. ===================================================================
  5552. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Toc.php,v
  5553. retrieving revision 1.1
  5554. diff -u -r1.1 Toc.php
  5555. --- Text/Wiki/Parse/Cowiki/Toc.php 21 Jul 2005 20:56:13 -0000 1.1
  5556. +++ Text/Wiki/Parse/Cowiki/Toc.php 28 Oct 2008 02:23:52 -0000
  5557. @@ -1,93 +1,81 @@
  5558. <?php
  5559.  
  5560. /**
  5561. -*
  5562. -* Looks through parsed text and builds a table of contents.
  5563. -*
  5564. -* @category Text
  5565. -*
  5566. -* @package Text_Wiki
  5567. -*
  5568. -* @author Paul M. Jones <pmjones@php.net>
  5569. -*
  5570. -* @license LGPL
  5571. -*
  5572. -* @version $Id: Toc.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5573. -*
  5574. -*/
  5575. + * Looks through parsed text and builds a table of contents.
  5576. + *
  5577. + * PHP version 4, 5
  5578. + *
  5579. + * @category Text
  5580. + * @package Text_Wiki
  5581. + * @author Paul M. Jones <pmjones@php.net>
  5582. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5583. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5584. + * @link http://pear.php.net/package/Text_Wiki
  5585. + */
  5586.  
  5587. /**
  5588. -*
  5589. -* Looks through parsed text and builds a table of contents.
  5590. -*
  5591. -* This class implements a Text_Wiki_Parse to find all heading tokens and
  5592. -* build a table of contents. The [[toc]] tag gets replaced with a list
  5593. -* of all the level-2 through level-6 headings.
  5594. -*
  5595. -* @category Text
  5596. -*
  5597. -* @package Text_Wiki
  5598. -*
  5599. -* @author Paul M. Jones <pmjones@php.net>
  5600. -*
  5601. -*/
  5602. -
  5603. -
  5604. -class Text_Wiki_Parse_Toc extends Text_Wiki_Parse {
  5605. -
  5606. -
  5607. + * Looks through parsed text and builds a table of contents.
  5608. + *
  5609. + * This class implements a Text_Wiki_Parse to find all heading tokens and
  5610. + * build a table of contents. The [[toc]] tag gets replaced with a list
  5611. + * of all the level-2 through level-6 headings.
  5612. + *
  5613. + * @category Text
  5614. + * @package Text_Wiki
  5615. + * @author Paul M. Jones <pmjones@php.net>
  5616. + * @copyright 2005 Paul M. Jones
  5617. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5618. + * @version Release: @package_version@
  5619. + * @link http://pear.php.net/package/Text_Wiki
  5620. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  5621. + */
  5622. +class Text_Wiki_Parse_Toc extends Text_Wiki_Parse
  5623. +{
  5624. +
  5625. +
  5626. /**
  5627. - *
  5628. - * The regular expression used to parse the source text and find
  5629. - * matches conforming to this rule. Used by the parse() method.
  5630. - *
  5631. - * @access public
  5632. - *
  5633. - * @var string
  5634. - *
  5635. - * @see parse()
  5636. - *
  5637. - */
  5638. -
  5639. + * The regular expression used to parse the source text and find
  5640. + * matches conforming to this rule. Used by the parse() method.
  5641. + *
  5642. + * @access public
  5643. + *
  5644. + * @var string
  5645. + *
  5646. + * @see parse()
  5647. + *
  5648. + */
  5649. var $regex = "/\n<toc( [^>]*?)?>\n/m";
  5650. -
  5651. -
  5652. +
  5653. +
  5654. /**
  5655. - *
  5656. - * Generates a replacement for the matched text.
  5657. - *
  5658. - * Token options are:
  5659. - *
  5660. - * 'type' => ['list_start'|'list_end'|'item_start'|'item_end'|'target']
  5661. - *
  5662. - * 'level' => The heading level (1-6).
  5663. - *
  5664. - * 'count' => Which entry number this is in the list.
  5665. - *
  5666. - * @access public
  5667. - *
  5668. - * @param array &$matches The array of matches from parse().
  5669. - *
  5670. - * @return string A token indicating the TOC collection point.
  5671. - *
  5672. - */
  5673. -
  5674. + * Generates a replacement for the matched text.
  5675. + *
  5676. + * Token options are:
  5677. + *
  5678. + * 'type' => ['list_start'|'list_end'|'item_start'|'item_end'|'target']
  5679. + *
  5680. + * 'level' => The heading level (1-6).
  5681. + *
  5682. + * 'count' => Which entry number this is in the list.
  5683. + *
  5684. + * @param array &$matches The array of matches from parse().
  5685. + *
  5686. + * @access public
  5687. + * @return string A token indicating the TOC collection point.
  5688. + *
  5689. + */
  5690. function process(&$matches)
  5691. {
  5692. $count = 0;
  5693. -
  5694. +
  5695. if (isset($matches[1])) {
  5696. $attr = $this->getAttrs(trim($matches[1]));
  5697. } else {
  5698. $attr = array();
  5699. }
  5700. -
  5701. - return $this->wiki->addToken(
  5702. - $this->rule,
  5703. - array(
  5704. - 'attr' => $attr
  5705. - )
  5706. - );
  5707. +
  5708. + return $this->wiki->addToken($this->rule,
  5709. + array('attr' => $attr));
  5710. }
  5711. }
  5712. -?>
  5713. \ No newline at end of file
  5714. +?>
  5715. Index: Text/Wiki/Parse/Cowiki/Tt.php
  5716. ===================================================================
  5717. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Tt.php,v
  5718. retrieving revision 1.1
  5719. diff -u -r1.1 Tt.php
  5720. --- Text/Wiki/Parse/Cowiki/Tt.php 21 Jul 2005 20:56:13 -0000 1.1
  5721. +++ Text/Wiki/Parse/Cowiki/Tt.php 28 Oct 2008 02:23:52 -0000
  5722. @@ -1,84 +1,75 @@
  5723. <?php
  5724.  
  5725. /**
  5726. -*
  5727. -* Find source text marked for teletype (monospace).
  5728. -*
  5729. -* @category Text
  5730. -*
  5731. -* @package Text_Wiki
  5732. -*
  5733. -* @author Paul M. Jones <pmjones@php.net>
  5734. -*
  5735. -* @license LGPL
  5736. -*
  5737. -* @version $Id: Tt.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5738. -*
  5739. -*/
  5740. + * Find source text marked for teletype (monospace).
  5741. +*
  5742. + * PHP version 4, 5
  5743. + *
  5744. + * @category Text
  5745. + * @package Text_Wiki
  5746. + * @author Paul M. Jones <pmjones@php.net>
  5747. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5748. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5749. + * @link http://pear.php.net/package/Text_Wiki
  5750. + */
  5751.  
  5752. /**
  5753. -*
  5754. -* Find source text marked for teletype (monospace).
  5755. -*
  5756. + * Find source text marked for teletype (monospace).
  5757. +*
  5758. * Defined by text surrounded by two curly braces. On parsing, the text
  5759. * itself is left in place, but the starting and ending instances of
  5760. * curly braces are replaced with tokens.
  5761. -*
  5762. +*
  5763. * Token options are:
  5764. -*
  5765. +*
  5766. * 'type' => ['start'|'end'] The starting or ending point of the
  5767. * teletype text. The text itself is left in the source.
  5768. -*
  5769. -* @category Text
  5770. -*
  5771. -* @package Text_Wiki
  5772. -*
  5773. -* @author Paul M. Jones <pmjones@php.net>
  5774. -*
  5775. -*/
  5776. -
  5777. -class Text_Wiki_Parse_Tt extends Text_Wiki_Parse {
  5778. -
  5779. -
  5780. +*
  5781. + * @category Text
  5782. + * @package Text_Wiki
  5783. + * @author Paul M. Jones <pmjones@php.net>
  5784. + * @copyright 2005 Paul M. Jones
  5785. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5786. + * @version Release: @package_version@
  5787. + * @link http://pear.php.net/package/Text_Wiki
  5788. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  5789. + */
  5790. +
  5791. +class Text_Wiki_Parse_Tt extends Text_Wiki_Parse
  5792. +{
  5793. +
  5794. +
  5795. /**
  5796. - *
  5797. - * The regular expression used to parse the source text.
  5798. - *
  5799. - * @access public
  5800. - *
  5801. - * @var string
  5802. - *
  5803. - * @see parse()
  5804. - *
  5805. - */
  5806. -
  5807. + * The regular expression used to parse the source text.
  5808. + *
  5809. + * @access public
  5810. + *
  5811. + * @var string
  5812. + *
  5813. + * @see parse()
  5814. + *
  5815. + */
  5816. +
  5817. var $regex = "/=({*?.*}*?)=/U";
  5818. -
  5819. -
  5820. +
  5821. +
  5822. /**
  5823. - *
  5824. - * Generates a replacement for the matched text.
  5825. - *
  5826. - * @access public
  5827. - *
  5828. - * @param array &$matches The array of matches from parse().
  5829. - *
  5830. - * @return string A pair of delimited tokens to be used as a
  5831. - * placeholder in the source text surrounding the teletype text.
  5832. - *
  5833. - */
  5834. -
  5835. + * Generates a replacement for the matched text.
  5836. + *
  5837. + * @param array &$matches The array of matches from parse().
  5838. + *
  5839. + * @access public
  5840. + * @return string A pair of delimited tokens to be used as a
  5841. + * placeholder in the source text surrounding the teletype text.
  5842. + *
  5843. + */
  5844. +
  5845. function process(&$matches)
  5846. {
  5847. - $start = $this->wiki->addToken(
  5848. - $this->rule, array('type' => 'start')
  5849. - );
  5850. -
  5851. - $end = $this->wiki->addToken(
  5852. - $this->rule, array('type' => 'end')
  5853. - );
  5854. -
  5855. + $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  5856. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  5857. +
  5858. return $start . $matches[1] . $end;
  5859. }
  5860. }
  5861. -?>
  5862. \ No newline at end of file
  5863. +?>
  5864. Index: Text/Wiki/Parse/Cowiki/Underline.php
  5865. ===================================================================
  5866. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Underline.php,v
  5867. retrieving revision 1.1
  5868. diff -u -r1.1 Underline.php
  5869. --- Text/Wiki/Parse/Cowiki/Underline.php 21 Jul 2005 20:56:13 -0000 1.1
  5870. +++ Text/Wiki/Parse/Cowiki/Underline.php 28 Oct 2008 02:23:52 -0000
  5871. @@ -1,79 +1,73 @@
  5872. <?php
  5873.  
  5874. /**
  5875. -*
  5876. -* Parses for bold text.
  5877. -*
  5878. -* @category Text
  5879. -*
  5880. -* @package Text_Wiki
  5881. -*
  5882. -* @author Paul M. Jones <pmjones@php.net>
  5883. -*
  5884. -* @license LGPL
  5885. -*
  5886. -* @version $Id: Underline.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5887. -*
  5888. -*/
  5889. + * Parses for bold text.
  5890. +*
  5891. + * PHP version 4, 5
  5892. + *
  5893. + * @category Text
  5894. + * @package Text_Wiki
  5895. + * @author Paul M. Jones <pmjones@php.net>
  5896. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5897. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  5898. + * @link http://pear.php.net/package/Text_Wiki
  5899. + */
  5900.  
  5901. /**
  5902. -*
  5903. -* Parses for bold text.
  5904. -*
  5905. -* This class implements a Text_Wiki_Rule to find source text marked for
  5906. -* strong emphasis (bold) as defined by text surrounded by three
  5907. -* single-quotes. On parsing, the text itself is left in place, but the
  5908. -* starting and ending instances of three single-quotes are replaced with
  5909. -* tokens.
  5910. -*
  5911. -* @category Text
  5912. -*
  5913. -* @package Text_Wiki
  5914. -*
  5915. -* @author Paul M. Jones <pmjones@php.net>
  5916. -*
  5917. -*/
  5918. -
  5919. -class Text_Wiki_Parse_Underline extends Text_Wiki_Parse {
  5920. -
  5921. -
  5922. + * Parses for bold text.
  5923. + *
  5924. + * This class implements a Text_Wiki_Rule to find source text marked for
  5925. + * strong emphasis (bold) as defined by text surrounded by three
  5926. + * single-quotes. On parsing, the text itself is left in place, but the
  5927. + * starting and ending instances of three single-quotes are replaced with
  5928. + * tokens.
  5929. + *
  5930. + * @category Text
  5931. + * @package Text_Wiki
  5932. + * @author Paul M. Jones <pmjones@php.net>
  5933. + * @copyright 2005 Paul M. Jones
  5934. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  5935. + * @version Release: @package_version@
  5936. + * @link http://pear.php.net/package/Text_Wiki
  5937. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  5938. + */
  5939. +
  5940. +class Text_Wiki_Parse_Underline extends Text_Wiki_Parse
  5941. +{
  5942. +
  5943. +
  5944. /**
  5945. - *
  5946. - * The regular expression used to parse the source text and find
  5947. - * matches conforming to this rule. Used by the parse() method.
  5948. - *
  5949. - * @access public
  5950. - *
  5951. - * @var string
  5952. - *
  5953. - * @see parse()
  5954. - *
  5955. - */
  5956. -
  5957. + * The regular expression used to parse the source text and find
  5958. + * matches conforming to this rule. Used by the parse() method.
  5959. + *
  5960. + * @access public
  5961. + *
  5962. + * @var string
  5963. + *
  5964. + * @see parse()
  5965. + *
  5966. + */
  5967. +
  5968. var $regex = '/_(()|.*)_/U';
  5969. -
  5970. -
  5971. +
  5972. +
  5973. /**
  5974. - *
  5975. - * Generates a replacement for the matched text. Token options are:
  5976. - *
  5977. - * 'type' => ['start'|'end'] The starting or ending point of the
  5978. - * emphasized text. The text itself is left in the source.
  5979. - *
  5980. - * @access public
  5981. - *
  5982. - * @param array &$matches The array of matches from parse().
  5983. - *
  5984. - * @return A pair of delimited tokens to be used as a placeholder in
  5985. - * the source text surrounding the text to be emphasized.
  5986. - *
  5987. - */
  5988. -
  5989. + * Generates a replacement for the matched text. Token options are:
  5990. + *
  5991. + * 'type' => ['start'|'end'] The starting or ending point of the
  5992. + * emphasized text. The text itself is left in the source.
  5993. + *
  5994. + * @param array &$matches The array of matches from parse().
  5995. + *
  5996. + * @access public
  5997. + * @return A pair of delimited tokens to be used as a placeholder in
  5998. + * the source text surrounding the text to be emphasized.
  5999. + */
  6000. function process(&$matches)
  6001. {
  6002. $start = $this->wiki->addToken($this->rule, array('type' => 'start'));
  6003. - $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  6004. + $end = $this->wiki->addToken($this->rule, array('type' => 'end'));
  6005. return $start . $matches[1] . $end;
  6006. }
  6007. }
  6008. -?>
  6009. \ No newline at end of file
  6010. +?>
  6011. Index: Text/Wiki/Parse/Cowiki/Url.php
  6012. ===================================================================
  6013. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Url.php,v
  6014. retrieving revision 1.2
  6015. diff -u -r1.2 Url.php
  6016. --- Text/Wiki/Parse/Cowiki/Url.php 14 Mar 2006 02:18:54 -0000 1.2
  6017. +++ Text/Wiki/Parse/Cowiki/Url.php 28 Oct 2008 02:23:52 -0000
  6018. @@ -1,80 +1,75 @@
  6019. <?php
  6020. -
  6021. /**
  6022. -*
  6023. -* Parse for URLS in the source text.
  6024. -*
  6025. -* @category Text
  6026. -*
  6027. -* @package Text_Wiki
  6028. -*
  6029. -* @author Paul M. Jones <pmjones@php.net>
  6030. -*
  6031. -* @license LGPL
  6032. -*
  6033. -* @version $Id: Url.php,v 1.2 2006/03/14 02:18:54 justinpatrin Exp $
  6034. -*
  6035. -*/
  6036. + * Parse for URLS in the source text.
  6037. + *
  6038. + * PHP version 4, 5
  6039. + *
  6040. + * @category Text
  6041. + * @package Text_Wiki
  6042. + * @author Paul M. Jones <pmjones@php.net>
  6043. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  6044. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  6045. + * @link http://pear.php.net/package/Text_Wiki
  6046. + */
  6047.  
  6048. /**
  6049. -*
  6050. -* Parse for URLS in the source text.
  6051. -*
  6052. -* Various URL markings are supported: inline (the URL by itself),
  6053. -* numbered or footnote reference (where the URL is enclosed in square
  6054. -* brackets), and named reference (where the URL is enclosed in square
  6055. -* brackets and has a name included inside the brackets). E.g.:
  6056. -*
  6057. -* inline -- http://example.com
  6058. -* numbered -- [http://example.com]
  6059. -* described -- [http://example.com Example Description]
  6060. -*
  6061. -* When rendering a URL token, this will convert URLs pointing to a .gif,
  6062. -* .jpg, or .png image into an inline <img /> tag (for the 'xhtml'
  6063. -* format).
  6064. -*
  6065. -* Token options are:
  6066. -*
  6067. -* 'type' => ['inline'|'footnote'|'descr'] the type of URL
  6068. -*
  6069. -* 'href' => the URL link href portion
  6070. -*
  6071. -* 'text' => the displayed text of the URL link
  6072. -*
  6073. -* @category Text
  6074. -*
  6075. -* @package Text_Wiki
  6076. -*
  6077. -* @author Paul M. Jones <pmjones@php.net>
  6078. -*
  6079. -*/
  6080. -
  6081. -class Text_Wiki_Parse_Url extends Text_Wiki_Parse {
  6082. -
  6083. -
  6084. + * Parse for URLS in the source text.
  6085. + *
  6086. + * Various URL markings are supported: inline (the URL by itself),
  6087. + * numbered or footnote reference (where the URL is enclosed in square
  6088. + * brackets), and named reference (where the URL is enclosed in square
  6089. + * brackets and has a name included inside the brackets). E.g.:
  6090. + *
  6091. + * inline -- http://example.com
  6092. + * numbered -- [http://example.com]
  6093. + * described -- [http://example.com Example Description]
  6094. + *
  6095. + * When rendering a URL token, this will convert URLs pointing to a .gif,
  6096. + * .jpg, or .png image into an inline <img /> tag (for the 'xhtml'
  6097. + * format).
  6098. + *
  6099. + * Token options are:
  6100. + *
  6101. + * 'type' => ['inline'|'footnote'|'descr'] the type of URL
  6102. + *
  6103. + * 'href' => the URL link href portion
  6104. + *
  6105. + * 'text' => the displayed text of the URL link
  6106. + *
  6107. + * @category Text
  6108. + * @package Text_Wiki
  6109. + * @author Paul M. Jones <pmjones@php.net>
  6110. + * @copyright 2005 Paul M. Jones
  6111. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  6112. + * @version Release: @package_version@
  6113. + * @link http://pear.php.net/package/Text_Wiki
  6114. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  6115. + */
  6116. +class Text_Wiki_Parse_Url extends Text_Wiki_Parse
  6117. +{
  6118. +
  6119. +
  6120. /**
  6121. - *
  6122. - * Keeps a running count of numbered-reference URLs.
  6123. - *
  6124. - * @access public
  6125. - *
  6126. - * @var int
  6127. - *
  6128. - */
  6129. -
  6130. + * Keeps a running count of numbered-reference URLs.
  6131. + *
  6132. + * @access public
  6133. + *
  6134. + * @var int
  6135. + *
  6136. + */
  6137. +
  6138. var $footnoteCount = 0;
  6139. -
  6140. -
  6141. +
  6142. +
  6143. /**
  6144. - *
  6145. - * URL schemes recognized by this rule.
  6146. - *
  6147. - * @access public
  6148. - *
  6149. - * @var array
  6150. - *
  6151. - */
  6152. -
  6153. + * URL schemes recognized by this rule.
  6154. + *
  6155. + * @access public
  6156. + *
  6157. + * @var array
  6158. + *
  6159. + */
  6160. +
  6161. var $conf = array(
  6162. 'schemes' => array(
  6163. 'http://',
  6164. @@ -85,77 +80,77 @@
  6165. 'mailto:'
  6166. )
  6167. );
  6168. -
  6169. -
  6170. +
  6171. +
  6172. /**
  6173. - *
  6174. - * Constructor.
  6175. - *
  6176. - * We override the constructor so we can comment the regex nicely.
  6177. - *
  6178. - * @access public
  6179. - *
  6180. - */
  6181. -
  6182. + * Constructor.
  6183. + *
  6184. + * We override the constructor so we can comment the regex nicely.
  6185. + *
  6186. + * @param Text_Wiki &$obj The calling object
  6187. + *
  6188. + * @access public
  6189. + */
  6190. function Text_Wiki_Parse_Url(&$obj)
  6191. {
  6192. parent::Text_Wiki_Parse($obj);
  6193. -
  6194. +
  6195. // convert the list of recognized schemes to a regex-safe string,
  6196. // where the pattern delim is a slash
  6197. - $tmp = array();
  6198. + $tmp = array();
  6199. $list = $this->getConf('schemes', array());
  6200. foreach ($list as $val) {
  6201. $tmp[] = preg_quote($val, '/');
  6202. }
  6203. $schemes = implode('|', $tmp);
  6204. -
  6205. +
  6206. // build the regex
  6207. $this->regex =
  6208. "($schemes)" . // allowed schemes
  6209. "(" . // start pattern
  6210. - "[^ \\/\"\'\(\)".$this->wiki->delim."]*\\/" . // no spaces, backslashes, slashes, double-quotes, single quotes, or delimiters;
  6211. +
  6212. + // no spaces, backslashes, slashes, double-quotes,
  6213. + // single quotes, or delimiters;
  6214. + "[^ \\/\"\'\(\)".$this->wiki->delim."]*\\/" .
  6215. +
  6216. +
  6217. ")*" . // end pattern
  6218. "[^ \\t\\n\\/\"\'\(\)".$this->wiki->delim."]*" .
  6219. "[A-Za-z0-9\\/?=&~_]";
  6220. }
  6221. -
  6222. -
  6223. +
  6224. +
  6225. /**
  6226. - *
  6227. - * Find three different kinds of URLs in the source text.
  6228. - *
  6229. - * @access public
  6230. - *
  6231. - */
  6232. -
  6233. + * Find three different kinds of URLs in the source text.
  6234. + *
  6235. + * @access public
  6236. + * @return void
  6237. + */
  6238. function parse()
  6239. {
  6240. // -------------------------------------------------------------
  6241. - //
  6242. + //
  6243. // Described-reference (named) URLs.
  6244. - //
  6245. -
  6246. + //
  6247. +
  6248. // the regular expression for this kind of URL
  6249. $tmp_regex = '/\(\((' . $this->regex . ')(\)\(([^\)\(]+))?\)\)/';
  6250.  
  6251. // use a custom callback processing method to generate
  6252. // the replacement text for matches.
  6253. - $this->wiki->source = preg_replace_callback(
  6254. - $tmp_regex,
  6255. - array(&$this, 'processDescr'),
  6256. - $this->wiki->source
  6257. - );
  6258. -
  6259. -
  6260. + $this->wiki->source = preg_replace_callback($tmp_regex,
  6261. + array(&$this, 'processDescr'),
  6262. + $this->wiki->source);
  6263. +
  6264. +
  6265. // -------------------------------------------------------------
  6266. - //
  6267. + //
  6268. // Numbered-reference (footnote-style) URLs.
  6269. - //
  6270. -
  6271. + //
  6272. +
  6273. // the regular expression for this kind of URL
  6274. /*$tmp_regex = '/\(\((' . $this->regex . ')\)\)/U';
  6275. -
  6276. +
  6277. // use a custom callback processing method to generate
  6278. // the replacement text for matches.
  6279. $this->wiki->source = preg_replace_callback(
  6280. @@ -163,41 +158,34 @@
  6281. array(&$this, 'processFootnote'),
  6282. $this->wiki->source
  6283. );*/
  6284. -
  6285. -
  6286. +
  6287. +
  6288. // -------------------------------------------------------------
  6289. - //
  6290. + //
  6291. // Normal inline URLs.
  6292. - //
  6293. -
  6294. + //
  6295. +
  6296. // the regular expression for this kind of URL
  6297. -
  6298. +
  6299. $tmp_regex = '/(^|[^A-Za-z])(' . $this->regex . ')(.*?)/';
  6300. -
  6301. +
  6302. // use the standard callback for inline URLs
  6303. - $this->wiki->source = preg_replace_callback(
  6304. - $tmp_regex,
  6305. - array(&$this, 'process'),
  6306. - $this->wiki->source
  6307. - );
  6308. + $this->wiki->source = preg_replace_callback($tmp_regex,
  6309. + array(&$this, 'process'),
  6310. + $this->wiki->source);
  6311. }
  6312. -
  6313. -
  6314. +
  6315. +
  6316. /**
  6317. - *
  6318. - * Process inline URLs.
  6319. - *
  6320. - * @param array &$matches
  6321. - *
  6322. - * @param array $matches An array of matches from the parse() method
  6323. - * as generated by preg_replace_callback. $matches[0] is the full
  6324. - * matched string, $matches[1] is the first matched pattern,
  6325. - * $matches[2] is the second matched pattern, and so on.
  6326. - *
  6327. - * @return string The processed text replacement.
  6328. - *
  6329. - */
  6330. -
  6331. + * Process inline URLs.
  6332. + *
  6333. + * @param array &$matches An array of matches from the parse() method
  6334. + * as generated by preg_replace_callback. $matches[0] is the full
  6335. + * matched string, $matches[1] is the first matched pattern,
  6336. + * $matches[2] is the second matched pattern, and so on.
  6337. + *
  6338. + * @return string The processed text replacement.
  6339. + */
  6340. function process(&$matches)
  6341. {
  6342. // set options
  6343. @@ -206,76 +194,75 @@
  6344. 'href' => $matches[2],
  6345. 'text' => $matches[2]
  6346. );
  6347. -
  6348. +
  6349. // tokenize
  6350. - return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[5];
  6351. + return $matches[1]
  6352. + . $this->wiki->addToken($this->rule, $options)
  6353. + . $matches[5];
  6354. }
  6355. -
  6356. -
  6357. +
  6358. +
  6359. /**
  6360. - *
  6361. - * Process numbered (footnote) URLs.
  6362. - *
  6363. - * Token options are:
  6364. - * @param array &$matches
  6365. - *
  6366. - * @param array $matches An array of matches from the parse() method
  6367. - * as generated by preg_replace_callback. $matches[0] is the full
  6368. - * matched string, $matches[1] is the first matched pattern,
  6369. - * $matches[2] is the second matched pattern, and so on.
  6370. - *
  6371. - * @return string The processed text replacement.
  6372. - *
  6373. - */
  6374. -
  6375. + * Process numbered (footnote) URLs.
  6376. + *
  6377. + * Token options are:
  6378. + *
  6379. + * @param array &$matches An array of matches from the parse() method
  6380. + * as generated by preg_replace_callback. $matches[0] is the full
  6381. + * matched string, $matches[1] is the first matched pattern,
  6382. + * $matches[2] is the second matched pattern, and so on.
  6383. + *
  6384. + * @return string The processed text replacement.
  6385. + *
  6386. + */
  6387. +
  6388. function processFootnote(&$matches)
  6389. {
  6390. - // keep a running count for footnotes
  6391. + // keep a running count for footnotes
  6392. $this->footnoteCount++;
  6393. -
  6394. +
  6395. // set options
  6396. $options = array(
  6397. 'type' => 'footnote',
  6398. 'href' => $matches[1],
  6399. 'text' => $this->footnoteCount
  6400. );
  6401. -
  6402. +
  6403. // tokenize
  6404. return $this->wiki->addToken($this->rule, $options);
  6405. }
  6406. -
  6407. -
  6408. +
  6409. +
  6410. /**
  6411. - *
  6412. - * Process described-reference (named-reference) URLs.
  6413. - *
  6414. - * Token options are:
  6415. - * 'type' => ['inline'|'footnote'|'descr'] the type of URL
  6416. - * 'href' => the URL link href portion
  6417. - * 'text' => the displayed text of the URL link
  6418. - *
  6419. - * @param array &$matches
  6420. - *
  6421. - * @param array $matches An array of matches from the parse() method
  6422. - * as generated by preg_replace_callback. $matches[0] is the full
  6423. - * matched string, $matches[1] is the first matched pattern,
  6424. - * $matches[2] is the second matched pattern, and so on.
  6425. - *
  6426. - * @return string The processed text replacement.
  6427. - *
  6428. - */
  6429. -
  6430. + * Process described-reference (named-reference) URLs.
  6431. + *
  6432. + * Token options are:
  6433. + * 'type' => ['inline'|'footnote'|'descr'] the type of URL
  6434. + * 'href' => the URL link href portion
  6435. + * 'text' => the displayed text of the URL link
  6436. + *
  6437. + * @param array &$matches An array of matches from the parse() method
  6438. + * as generated by preg_replace_callback. $matches[0] is the full
  6439. + * matched string, $matches[1] is the first matched pattern,
  6440. + * $matches[2] is the second matched pattern, and so on.
  6441. + *
  6442. + * @return string The processed text replacement.
  6443. + *
  6444. + */
  6445. +
  6446. function processDescr(&$matches)
  6447. {
  6448. + $result = isset($matches[5]) && strlen($matches[5]);
  6449. +
  6450. // set options
  6451. $options = array(
  6452. 'type' => 'descr',
  6453. 'href' => $matches[1],
  6454. - 'text' => isset($matches[5]) && strlen($matches[5]) ? $matches[5] : $matches[1],
  6455. + 'text' => $result ? $matches[5] : $matches[1],
  6456. );
  6457.  
  6458. // tokenize
  6459. return $this->wiki->addToken($this->rule, $options);
  6460. }
  6461. }
  6462. -?>
  6463. \ No newline at end of file
  6464. +?>
  6465. Index: Text/Wiki/Parse/Cowiki/Wikilink.php
  6466. ===================================================================
  6467. RCS file: /repository/pear/Text_Wiki/Text/Wiki/Parse/Cowiki/Wikilink.php,v
  6468. retrieving revision 1.5
  6469. diff -u -r1.5 Wikilink.php
  6470. --- Text/Wiki/Parse/Cowiki/Wikilink.php 8 Dec 2006 08:23:51 -0000 1.5
  6471. +++ Text/Wiki/Parse/Cowiki/Wikilink.php 28 Oct 2008 02:23:52 -0000
  6472. @@ -1,89 +1,83 @@
  6473. <?php
  6474. -
  6475. /**
  6476. -*
  6477. -* Parse for links to wiki pages.
  6478. -*
  6479. -* @category Text
  6480. -*
  6481. -* @package Text_Wiki
  6482. -*
  6483. -* @author Paul M. Jones <pmjones@php.net>
  6484. -*
  6485. -* @license LGPL
  6486. -*
  6487. -* @version $Id: Wikilink.php,v 1.5 2006/12/08 08:23:51 justinpatrin Exp $
  6488. -*
  6489. -*/
  6490. + * Parse for links to wiki pages.
  6491. + *
  6492. + * PHP version 4, 5
  6493. + *
  6494. + * @category Text
  6495. + * @package Text_Wiki
  6496. + * @author Paul M. Jones <pmjones@php.net>
  6497. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  6498. + * @version CVS: $Id: Phplookup.php,v 1.1 2005/07/21 20:56:13 justinpatrin Exp $
  6499. + * @link http://pear.php.net/package/Text_Wiki
  6500. + */
  6501.  
  6502. /**
  6503. -*
  6504. -* Parse for links to wiki pages.
  6505. -*
  6506. -* Wiki page names are typically in StudlyCapsStyle made of
  6507. -* WordsSmashedTogether.
  6508. -*
  6509. -* You can also create described links to pages in this style:
  6510. -* [WikiPageName nice text link to use for display]
  6511. -*
  6512. -* The token options for this rule are:
  6513. -*
  6514. -* 'page' => the wiki page name.
  6515. -*
  6516. -* 'text' => the displayed link text.
  6517. -*
  6518. -* 'anchor' => a named anchor on the target wiki page.
  6519. -*
  6520. -* @category Text
  6521. -*
  6522. -* @package Text_Wiki
  6523. -*
  6524. -* @author Paul M. Jones <pmjones@php.net>
  6525. -*
  6526. -*/
  6527. + * Parse for links to wiki pages.
  6528. + *
  6529. + * Wiki page names are typically in StudlyCapsStyle made of
  6530. + * WordsSmashedTogether.
  6531. + *
  6532. + * You can also create described links to pages in this style:
  6533. + * [WikiPageName nice text link to use for display]
  6534. + *
  6535. + * The token options for this rule are:
  6536. + *
  6537. + * 'page' => the wiki page name.
  6538. + *
  6539. + * 'text' => the displayed link text.
  6540. + *
  6541. + * 'anchor' => a named anchor on the target wiki page.
  6542. + *
  6543. + * @category Text
  6544. + * @package Text_Wiki
  6545. + * @author Paul M. Jones <pmjones@php.net>
  6546. + * @copyright 2005 Paul M. Jones
  6547. + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  6548. + * @version Release: @package_version@
  6549. + * @link http://pear.php.net/package/Text_Wiki
  6550. + * @see Text_Wiki_Parse::Text_Wiki_Parse()
  6551. + */
  6552. +class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse
  6553. +{
  6554.  
  6555. -class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse {
  6556. -
  6557. var $conf = array (
  6558. 'ext_chars' => false,
  6559. 'utf-8' => false
  6560. );
  6561. -
  6562. +
  6563. /**
  6564. - *
  6565. - * Constructor.
  6566. - *
  6567. - * We override the Text_Wiki_Parse constructor so we can
  6568. - * explicitly comment each part of the $regex property.
  6569. - *
  6570. - * @access public
  6571. - *
  6572. - * @param object &$obj The calling "parent" Text_Wiki object.
  6573. - *
  6574. - */
  6575. -
  6576. + * Constructor.
  6577. + *
  6578. + * We override the Text_Wiki_Parse constructor so we can
  6579. + * explicitly comment each part of the $regex property.
  6580. + *
  6581. + * @param object &$obj The calling "parent" Text_Wiki object.
  6582. + *
  6583. + * @access public
  6584. + */
  6585. function Text_Wiki_Parse_Wikilink(&$obj)
  6586. {
  6587. parent::Text_Wiki_Parse($obj);
  6588. if ($this->getConf('utf-8')) {
  6589. - $upper = 'A-Z\p{Lu}';
  6590. - $lower = 'a-z0-9\p{Ll}';
  6591. - $either = 'A-Za-z0-9\p{L}';
  6592. + $upper = 'A-Z\p{Lu}';
  6593. + $lower = 'a-z0-9\p{Ll}';
  6594. + $either = 'A-Za-z0-9\p{L}';
  6595. } else if ($this->getConf('ext_chars')) {
  6596. - // use an extended character set; this should
  6597. - // allow for umlauts and so on. taken from the
  6598. - // Tavi project defaults.php file.
  6599. - $upper = 'A-Z\xc0-\xde';
  6600. - $lower = 'a-z0-9\xdf-\xfe';
  6601. - $either = 'A-Za-z0-9\xc0-\xfe';
  6602. - } else {
  6603. - // the default character set, should be fine
  6604. - // for most purposes.
  6605. - $upper = "A-Z";
  6606. - $lower = "a-z0-9";
  6607. - $either = "A-Za-z0-9";
  6608. - }
  6609. -
  6610. + // use an extended character set; this should
  6611. + // allow for umlauts and so on. taken from the
  6612. + // Tavi project defaults.php file.
  6613. + $upper = 'A-Z\xc0-\xde';
  6614. + $lower = 'a-z0-9\xdf-\xfe';
  6615. + $either = 'A-Za-z0-9\xc0-\xfe';
  6616. + } else {
  6617. + // the default character set, should be fine
  6618. + // for most purposes.
  6619. + $upper = "A-Z";
  6620. + $lower = "a-z0-9";
  6621. + $either = "A-Za-z0-9";
  6622. + }
  6623. +
  6624. // build the regular expression for finding WikiPage names.
  6625. $this->regex =
  6626. "(!?" . // START WikiPage pattern (1)
  6627. @@ -100,61 +94,52 @@
  6628. "[-_$either]" . // 1 dash, alpha, digit, or underscore
  6629. ")?)?)"; // end subpatterns (/4)(/3)(/2)
  6630. }
  6631. -
  6632. -
  6633. +
  6634. +
  6635. /**
  6636. - *
  6637. - * First parses for described links, then for standalone links.
  6638. - *
  6639. - * @access public
  6640. - *
  6641. - * @return void
  6642. - *
  6643. - */
  6644. -
  6645. + * First parses for described links, then for standalone links.
  6646. + *
  6647. + * @access public
  6648. + *
  6649. + * @return void
  6650. + */
  6651. function parse()
  6652. {
  6653. if ($this->getConf('utf-8')) {
  6654. - $either = 'A-Za-z0-9\p{L}';
  6655. + $either = 'A-Za-z0-9\p{L}';
  6656. } else if ($this->getConf('ext_chars')) {
  6657. - $either = "A-Za-z0-9\xc0-\xfe";
  6658. - } else {
  6659. - $either = "A-Za-z0-9";
  6660. - }
  6661. -
  6662. + $either = "A-Za-z0-9\xc0-\xfe";
  6663. + } else {
  6664. + $either = "A-Za-z0-9";
  6665. + }
  6666. +
  6667. // described wiki links
  6668. $tmp_regex = '/\(\(' . /*$this->regex*/ '(['.$either.'\s:\.]*?)((\#['.$either.'\s:\.](['.$either.'\s:\.]*?)?)?)' . '(\)\((.+?))?\)\)/'.($this->getConf('utf-8') ? 'u' : '');
  6669. - $this->wiki->source = preg_replace_callback(
  6670. - $tmp_regex,
  6671. - array(&$this, 'processDescr'),
  6672. - $this->wiki->source
  6673. - );
  6674. -
  6675. +
  6676. + $this->wiki->source = preg_replace_callback($tmp_regex,
  6677. + array(&$this, 'processDescr'),
  6678. + $this->wiki->source);
  6679. +
  6680. if ($this->getConf('camel_case')) {
  6681. // standalone wiki links
  6682. $tmp_regex = '/(^|[^$either\-_])(\)\))?' . $this->regex . '(\(\()?/'.($this->getConf('utf-8') ? 'u' : '');
  6683. - $this->wiki->source = preg_replace_callback(
  6684. - $tmp_regex,
  6685. +
  6686. + $this->wiki->source = preg_replace_callback($tmp_regex,
  6687. array(&$this, 'process'),
  6688. - $this->wiki->source
  6689. - );
  6690. + $this->wiki->source);
  6691. }
  6692. }
  6693. -
  6694. -
  6695. +
  6696. +
  6697. /**
  6698. - *
  6699. - * Generate a replacement for described links.
  6700. - *
  6701. - * @access public
  6702. - *
  6703. - * @param array &$matches The array of matches from parse().
  6704. - *
  6705. - * @return A delimited token to be used as a placeholder in
  6706. - * the source text, plus any text priot to the match.
  6707. - *
  6708. - */
  6709. -
  6710. + * Generate a replacement for described links.
  6711. + *
  6712. + * @param array &$matches The array of matches from parse().
  6713. + *
  6714. + * @return A delimited token to be used as a placeholder in
  6715. + * the source text, plus any text priot to the match.
  6716. + * @access public
  6717. + */
  6718. function processDescr(&$matches)
  6719. {
  6720. // set the options
  6721. @@ -166,31 +151,27 @@
  6722. if ($options['text'] == $options['page']) {
  6723. $options['text'] = '';
  6724. }
  6725. -
  6726. +
  6727. // create and return the replacement token and preceding text
  6728. return $this->wiki->addToken($this->rule,
  6729. array_merge(array('type' => 'start'), $options)).
  6730. $options['text'].
  6731. $this->wiki->addToken($this->rule,
  6732. array_merge(array('type' => 'end'), $options));
  6733. -
  6734. +
  6735. }
  6736. -
  6737. -
  6738. +
  6739. +
  6740. /**
  6741. - *
  6742. - * Generate a replacement for standalone links.
  6743. - *
  6744. - *
  6745. - * @access public
  6746. - *
  6747. - * @param array &$matches The array of matches from parse().
  6748. - *
  6749. - * @return A delimited token to be used as a placeholder in
  6750. - * the source text, plus any text prior to the match.
  6751. - *
  6752. - */
  6753. -
  6754. + * Generate a replacement for standalone links.
  6755. + *
  6756. + * @param array &$matches The array of matches from parse().
  6757. + *
  6758. + * @access public
  6759. + *
  6760. + * @return A delimited token to be used as a placeholder in
  6761. + * the source text, plus any text prior to the match.
  6762. + */
  6763. function process(&$matches)
  6764. {
  6765. // when prefixed with !, it's explicitly not a wiki link.
  6766. @@ -204,7 +185,7 @@
  6767. if ($matches[2] == '))' && $matches[7] == '((') {
  6768. return $matches[1] . $matches[3] . $matches[4];
  6769. }
  6770. -
  6771. +
  6772. // set the options
  6773. $options = array(
  6774. 'page' => $matches[3],
  6775. @@ -224,4 +205,4 @@
  6776. $matches[7];
  6777. }
  6778. }
  6779. -?>
  6780. \ No newline at end of file
  6781. +?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement