Ejemplo n.º 1
0
 public function format($str)
 {
     if (module_const('is_cache', false)) {
         $store_key = array('__hatenaformat_format', $str);
         if (Store::has($store_key)) {
             return Store::get($store_key);
         }
     }
     $str = HatenaSyntax::render($str, Text::dict(module_const('option')) + array('headerlevel' => 3, 'htmlescape' => true, 'linktitlehandler' => 'HatenaFormat::linktitleHandler', 'keywordlinkhandler' => 'HatenaFormat::keywordlinkHandler'));
     if (module_const('is_cache', false)) {
         Store::set($store_key, $str, self::CACHE_EXPIRE);
     }
     return $str;
 }
Ejemplo n.º 2
0
 protected function __fm_description__()
 {
     return HatenaSyntax::render($this->description());
 }
Ejemplo n.º 3
0
 /**
  * パッケージの詳細
  * @param string $package_name パッケージ名
  * @param string $path リポジトリのパス
  * @request string $lang ロケール
  * @request string $tag タグ
  * @context OpenpearPackage $package パッケージ
  * @context string $body 説明
  */
 public function document_browse($package_name, $path = '')
 {
     $lang = $this->in_vars('lang', Gettext::lang());
     if (empty($path)) {
         $this->redirect_method('document_browse', $package_name, '/' . $lang . '/README');
     } else {
         if (strlen($path) > 4) {
             $lang = substr($path, 1, 2);
         }
     }
     $package = C(OpenpearPackage)->find_get(Q::eq('name', $package_name));
     $path = rtrim(ltrim($path, ' /.'), '/');
     $root = File::absolute(OpenpearConfig::svn_root(), implode('/', array($package->name(), 'doc')));
     $repo_path = File::absolute($root, $path);
     $this->vars('package', $package);
     try {
         $body = Subversion::cmd('cat', array($repo_path));
     } catch (Exception $e) {
         $body = '';
     }
     if (empty($body)) {
         Http::status_header(404);
         $body = '* Not found.' . PHP_EOL;
         $body .= 'Requested page is not found in our repositories.';
     }
     $this->vars('lang', $lang);
     $this->vars('body', HatenaSyntax::render($body));
     $this->vars('tree', Subversion::cmd('list', array($root . '/' . $lang), array('recursive' => 'recursive')));
     $this->add_vars_other_tree($package_name, 'doc');
 }
Ejemplo n.º 4
0
    foreach ($lines as &$line) {
        $line = htmlspecialchars($line, ENT_QUOTES, 'utf-8');
    }
    $body = join(PHP_EOL, $lines);
    return '<pre class="superpre ' . htmlspecialchars($type, ENT_QUOTES, 'utf-8') . '">' . PHP_EOL . $body . '</pre>';
}
function keywordLinkHandler($path)
{
    return './' . $path;
}
function linkTitleHandler($url)
{
    return $url;
}
// オプションは全て省略可。第二引数自体も省略可。
echo HatenaSyntax::render($str, array('headerlevel' => 3, 'id' => 'hoge', 'htmlescape' => false, 'sectionclass' => 'section', 'footnoteclass' => 'footnote', 'keywordlinkhanlder' => 'keywordLinkHandler', 'superprehandler' => 'spreHandler', 'linktitlehandler' => 'linkTitleHandler'));
/* 結果
<div class="section">
<h3>header1<a name="ea703e7aa1efda0064eaa507d9e8ab7e_header_0" id="ea703e7aa1efda0064eaa507d9e8ab7e_header_0"></a></h3>
<div class="toc"><ol>
<li>
<a href="#ea703e7aa1efda0064eaa507d9e8ab7e_header_0">header1</a>
<ol>
<li>
<a href="#ea703e7aa1efda0064eaa507d9e8ab7e_header_1">header2</a>
<ol>
<li><a href="#ea703e7aa1efda0064eaa507d9e8ab7e_header_2">blockquote header</a></li>
</ol>
</li>
</ol>
</li>
Ejemplo n.º 5
0
 public function setChangelog($value)
 {
     $this->pm('changelog', HatenaSyntax::render($value, $this->_hatena_config));
 }