Exemple #1
0
 /**
  * @param string
  * @return PEG_IContext
  */
 protected static function context($str)
 {
     $str = str_replace(array("\r\n", "\r"), "\n", $str);
     $str = strpos('<!--', $str) === false ? $str : HatenaSyntax_CommentRemover::remove($str);
     return PEG::context(preg_split("/\n/", $str));
 }
<?php

include_once dirname(__FILE__) . '/../../t.php';
$t = new lime_test();
$remover = new HatenaSyntax_CommentRemover();
$text = ">|php|\n<!-- -->||<";
$t->is($remover->remove($text), $text);
$text = "<!--\n>||\nhogehoge||<\n-->";
$t->is($remover->remove($text), '');
$text = <<<EOS
<!-- hoge -->
>|xml|
<!--comment-->||<
<!--
>||

||<
-->
EOS;
$expected = <<<EOS

>|xml|
<!--comment-->||<

EOS;
$t->is($remover->remove($text), $expected);