コード例 #1
0
ファイル: Markdown.php プロジェクト: bruensicke/li3_markdown
 public function render($template, $data = array(), array $options = array())
 {
     $defaults = array('context' => array());
     $options += $defaults;
     $this->_context = $options['context'] + $this->_context;
     $this->_data = (array) $data + $this->_vars;
     $template__ = $template;
     unset($template, $defaults, $data);
     if ($this->_config['extract']) {
         extract($this->_data, EXTR_OVERWRITE);
     } elseif ($this->_view) {
         extract((array) $this->_view->outputFilters, EXTR_OVERWRITE);
     }
     ob_start();
     include $template__;
     $content = ob_get_clean();
     $_type = $this->getType($template__);
     return $_type == 'md' ? MarkdownExtended($content) : $content;
 }
コード例 #2
0
ファイル: docs.php プロジェクト: bamper/laravel.com
 /**
  * Content
  *
  * Load the content based on the section and page in the uri.
  *
  * @param  string $section
  * @param  string $page
  * @return string
  */
 public static function content($section = null, $page = null)
 {
     if (!$section) {
         $markdown_file = 'docs/home';
     } else {
         $file = 'docs/' . $section . '/' . $page;
         $markdown_file = rtrim($file, '/');
     }
     if ($contents = Cache::get(str_replace('/', '_', $markdown_file))) {
         return $contents;
     }
     if (!is_file(path('storage') . $markdown_file . '.md')) {
         // Check for a home file
         if (is_file(path('storage') . $markdown_file . '/home.md')) {
             $markdown_file .= '/home';
         } else {
             return null;
         }
     }
     $contents = MarkdownExtended(File::get(path('storage') . $markdown_file . '.md'));
     Cache::put(str_replace('/', '_', $markdown_file), $contents, 60);
     return $contents;
 }
コード例 #3
0
ファイル: functions.php プロジェクト: dongcheng/daux
function load_page($tree, $url_params)
{
    if (count($url_params) > 0) {
        $branch = find_branch($tree, $url_params);
    } else {
        $branch = current($tree);
    }
    $page = array();
    if (isset($branch['type']) && $branch['type'] == 'file') {
        $html = '';
        if ($branch['name'] !== 'index') {
            $page['title'] = $branch['title'];
            $page['modified'] = filemtime($branch['path']);
        }
        $html .= MarkdownExtended(file_get_contents($branch['path']));
        $page['html'] = $html;
    } else {
        $page['title'] = "Oh no";
        $page['html'] = "<h3>Oh No. That page doesn't exist</h3>";
    }
    return $page;
}
コード例 #4
0
function load_page($tree)
{
    $branch = find_branch($tree);
    if (isset($branch['type']) && $branch['type'] == 'file') {
        $html = '';
        if ($branch['name'] !== 'index') {
            $html .= '
				<div class="page-header">
					<a href="https://github.com/jpwilliams/I-A-3-Documentation/edit/master/' . $branch['path'] . '" target="_blank" title="You must be logged into GitHub for this to work." class="btn btn-primary pull-right improve-button">
						Improve This Page
					</a>
					<h1>' . $branch['title'] . '</h1>
				</div>
			';
        }
        $html .= MarkdownExtended(file_get_contents('https://raw.github.com/jpwilliams/I-A-3-Documentation/master/' . $branch['path']));
        return $html;
    } else {
        return 'Oh no! That page doesn\'t exist!';
    }
}
コード例 #5
0
<?php 
error_reporting(E_ALL);
set_error_handler("error_function");
function error_function($error_level, $error_message, $error_file, $error_line, $error_context)
{
    $res = "<h1>Error</h1><table>";
    $res .= "<tr><th>error_level:</th><td>{$error_level}</td></tr>";
    $res .= "<tr><th>error_message:</th><td>{$error_message}</td></tr>";
    $res .= "<tr><th>error_file:</th><td>{$error_file}</td></tr>";
    $res .= "<tr><th>error_line:</th><td>{$error_line}</td></tr>";
    $res .= "<tr><th>error_context:</th><td>{$error_context}</td></tr></table>";
    echo $res;
    die;
}
require_once '../markdown_extended_stylish.php';
if (isset($_POST["markdown"]) && !empty($_POST["markdown"])) {
    $markdown = $_POST["markdown"];
    // Always add a 'prettyprint' to <pre> elements
    echo MarkdownExtended($markdown, array('pre' => 'prettyprint'));
}
die;
コード例 #6
0
ファイル: docs.php プロジェクト: brkrishna/freelance
 /**
  * Does the actual work of reading in and parsing the help file.
  *
  * @param  array  $segments The uri_segments array.
  */
 private function read_page($segments = array())
 {
     $defaultType = $this->docsTypeApp;
     // Strip the 'controller name
     if ($segments[1] == $this->router->fetch_class()) {
         array_shift($segments);
     }
     // Is this core, app, or module?
     $type = array_shift($segments);
     if (empty($type)) {
         $type = $defaultType;
     }
     // Is it a module?
     if ($type != $this->docsTypeApp && $type != $this->docsTypeBf) {
         $modules = module_list();
         if (in_array($type, $modules)) {
             $module = $type;
             $type = $this->docsTypeMod;
         } else {
             $type = $defaultType;
         }
     }
     // for now, assume we are using Markdown files as the only
     // allowed format. With an extension of '.md'
     if (count($segments)) {
         $file = implode('/', $segments) . $this->docsExt;
     } else {
         $file = 'index' . $this->docsExt;
         if ($type != $this->docsTypeMod && !is_file(APPPATH . $this->docsDir . '/' . $file)) {
             $type = $this->docsTypeBf;
         }
     }
     switch ($type) {
         case $this->docsTypeBf:
             $content = is_file(BFPATH . $this->docsDir . '/' . $file) ? file_get_contents(BFPATH . $this->docsDir . '/' . $file) : '';
             break;
         case $this->docsTypeApp:
             $content = is_file(APPPATH . $this->docsDir . '/' . $file) ? file_get_contents(APPPATH . $this->docsDir . '/' . $file) : '';
             break;
         case $this->docsTypeMod:
             // Assume it's a module
             $mod_path = module_path($module, $this->docsDir);
             $content = is_file($mod_path . '/' . $file) ? file_get_contents($mod_path . '/' . $file) : '';
             break;
     }
     // Parse the file
     $this->load->helper('markdown_extended');
     $content = MarkdownExtended($content);
     return trim($content);
 }
コード例 #7
0
ファイル: docsearch.php プロジェクト: brkrishna/freelance
 /**
  * Handles extracting the text surrounding our match and basic match formatting.
  *
  * @param $excerpt
  * @param $term
  * @param $match_string
  *
  * @return string
  */
 private function build_extract($excerpt, $term, $match_string)
 {
     // Find the character positions within the string that our match was found at.
     // That way we'll know from what positions before and after this we want to grab it in.
     $start_offset = stripos($excerpt, $match_string);
     // Modify the start and end positions based on $this->excerpt_length / 2.
     $buffer = floor($this->excerpt_length / 2);
     // Adjust our start position
     $start_offset = $start_offset - $buffer;
     if ($start_offset < 0) {
         $start_offset = 0;
     }
     $extract = substr($excerpt, $start_offset);
     $extract = strip_tags(MarkdownExtended($extract));
     $extract = character_limiter($extract, $this->excerpt_length);
     // Wrap the search term in a span we can style.
     $extract = str_ireplace($term, '<span class="term-hilight">' . $term . '</span>', $extract);
     return $extract;
 }
コード例 #8
0
ファイル: html.php プロジェクト: sunny/edith
<head>
  <meta charset="utf-8">
  <title><?php 
echo h(ucfirst($page->name));
?>
</title>
  <meta content="width=device-width" name="viewport" />
  <link rel="shortcut icon" href="<?php 
echo EDITH_URI;
?>
/public/icon.png" />
  <link rel="stylesheet" href="<?php 
echo EDITH_URI;
?>
/public/html.css" />
</head>
<body>

<?php 
echo MarkdownExtended($page->text);
?>

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="public/vendor/jquery.js"><\/script>')</script>
  <script src="<?php 
echo EDITH_URI;
?>
/public/html.js"></script>
</body>
</html>
コード例 #9
0
ファイル: docs.php プロジェクト: brkrishna/freelance
 /**
  * Does the actual work of reading in and parsing the help file.
  *
  * @param  array  $segments The uri_segments array.
  *
  * @return string
  */
 private function read_page($segments = array())
 {
     $content = null;
     $defaultType = $this->docsTypeApp;
     // Strip the controller name
     if ($segments[1] == $this->router->fetch_class()) {
         array_shift($segments);
     }
     // Is this core, app, or module?
     $type = array_shift($segments);
     if (empty($type)) {
         $type = $defaultType;
     }
     // For now, assume Markdown files are the only allowed format, with an
     // extension of '.md'
     if (count($segments)) {
         $file = implode('/', $segments) . $this->docsExt;
     } else {
         $file = 'index' . $this->docsExt;
         if ($type != $this->docsTypeMod && !is_file(APPPATH . $this->docsDir . '/' . $file)) {
             $type = $this->docsTypeBf;
         }
     }
     // First try to load from Activities or Bonfire.
     switch ($type) {
         case $this->docsTypeBf:
             $content = is_file(BFPATH . $this->docsDir . '/' . $file) ? file_get_contents(BFPATH . $this->docsDir . '/' . $file) : '';
             break;
         case $this->docsTypeApp:
             $content = is_file(APPPATH . $this->docsDir . '/' . $file) ? file_get_contents(APPPATH . $this->docsDir . '/' . $file) : '';
             break;
     }
     // If the file wasn't found, try to find a module with the content.
     if (empty($content)) {
         $module = array_shift($segments);
         // If anything's left on $segments, it's probably a filename
         $fileName = count($segments) ? array_shift($segments) : 'index';
         $fileName .= '.md';
         // Developer docs for modules should be found under the
         // '{module}/docs/developer' path.
         $addPath = $type == $this->docsTypeBf ? '/' . $this->docsTypeBf . '/' : '/';
         // This time, try it based on the name of the segment brought in
         list($full_path, $file) = Modules::find($fileName, $module, $this->docsDir . $addPath);
         if ($full_path) {
             $content = file_get_contents($full_path . $file);
         }
     }
     // If the content is still empty, load the application/docs/404 file
     // so that we have a customizable not found file.
     if (empty($content)) {
         $content = is_file(APPPATH . $this->docsDir . '/_404.md') ? file_get_contents(APPPATH . $this->docsDir . '/_404.md') : '';
     }
     // Parse the file
     $this->load->helper('markdown_extended');
     $content = MarkdownExtended($content);
     return trim($content);
 }
コード例 #10
0
<?php

require 'markdown_extended.php';
echo MarkdownExtended($_POST['content']);
コード例 #11
0
ファイル: Markdown.php プロジェクト: johnny13/li3_markdown
 /**
  * This public static instance on the function allows you to
  * call the markdown render in your controller file.
  *
  * Example:
  * use li3_markdown\extensions\helper\Markdown;
  * $beauty = Markdown::rendermarkdown($rawtext);
  *
  * @link http://michelf.com/projects/php-markdown/
  * @param string $string Content that we want to be parsed from `markdown` into `HTML`.
  * @return string `HTML` ready string.
  */
 public static function rendermarkdown($string)
 {
     return MarkdownExtended($string);
 }
コード例 #12
0
ファイル: Markdown.php プロジェクト: bruensicke/li3_markdown
 /**
  * Parse a string containing `markdown` markup syntax.
  *
  * @link http://michelf.com/projects/php-markdown/
  * @param string $string Content that we want to be parsed from `markdown` into `HTML`.
  * @return string `HTML` ready string.
  */
 public function render($string)
 {
     return MarkdownExtended($string);
 }
コード例 #13
0
ファイル: md2html.php プロジェクト: dalinhuang/Z
    closedir($dir);
}
$config = array("template" => "Template/temp.html", "style" => "Template/Style/Github2.css");
$template = @file_get_contents($config['template']);
$style = @file_get_contents($config['style']);
$dir = ROOT . "/../Docs";
$out_dir = ROOT . "/../HTML";
echo "\nGenerate html file\n\n";
$files = glob($dir . "/*.md");
$file_tags = array();
foreach ($files as $file) {
    echo "Processing file " . $file . "\n";
    $filename = pathinfo($file)['filename'];
    $markdown = @file_get_contents($file);
    //$content = MarkdownExtra::defaultTransform($markdown);
    $content = MarkdownExtended($markdown);
    $tags = get_tags_arr(strip_tags($content));
    // 提取文章的关键词
    sort($tags);
    $tag_str = implode(",", $tags);
    $html = $template;
    $html = str_replace("{{title}}", $filename, $html);
    $html = str_replace("{{style}}", $style, $html);
    $html = str_replace("{{content}}", $content, $html);
    $html = str_replace("{{tags}}", $tag_str, $html);
    $htmlfile = $filename . ".html";
    $file_tags[] = array("file" => $htmlfile, "tags" => $tags);
    file_put_contents($out_dir . "/" . $htmlfile, $html);
}
echo "\nGenerate related pages\n\n";
foreach ($file_tags as $file_tag) {
コード例 #14
0
        foreach ($properties['params'] as $title => $value) {
            $value = is_array($value) ? implode("|", $value) : $value;
            $params .= "<li style='padding-left:15px;line-height:20px'>{$title} - {$value}</li>\n";
        }
        $returns = "";
        if (isset($properties['returns']) && count($properties['returns']) > 1) {
            $val = is_array($properties['returns']['types']) ? implode($properties['returns']['types'], "|") : $properties['returns']['types'];
            $returns .= $val . " - " . $properties['returns']['desc'];
        } else {
            $returns .= "null";
        }
        $markdown = "";
        $extraTitle = ltrim($funcPerm, ".");
        echo $extraTitle . ".md\n\r";
        if (is_file("./detail/" . $extraTitle . ".md")) {
            $markdown = MarkdownExtended(file_get_contents("./detail/" . $extraTitle . ".md"));
        }
        //$panel=<<<EOF
        $subPanels .= <<<EOF


       <div id='{$linker}' title='{$func}' data-nav='nav_{$id}' class='panel'>
       <div class='source'>
          <h3><a class='collapsed' onclick='toggleSource("{$linker}",this)'>Show Source</a></h3>

            <div class='viewsource' id='source_{$linker}' style='display:none'>
            <pre style='padding-left:25px'><code>
            {$properties['code']}
            </code></pre>
             </div>
      </div>