Example #1
0
 function md($str)
 {
     $markdownParser = new MarkdownExtraParser();
     // Parse the loaded source.
     return $markdownParser->transformMarkdown($str);
 }
Example #2
0
 public function extra($file)
 {
     $extras = new MarkdownExtraParser();
     return $extras->transformMarkdown($file);
 }
 /**
  * {@inheritDoc}
  */
 public function transformMarkdown($text)
 {
     if ($this->features['no_html']) {
         $text = htmlspecialchars($text, ENT_NOQUOTES);
     }
     return parent::transformMarkdown($text);
 }
Example #4
0
 /**
  * Converts a description node into something HTML-appropriate.
  *
  * @param  array  $description The description node to handle.
  * @return string              The description as it has been understood.
  */
 public static function descriptionAsHTML(array $description)
 {
     $output = array();
     foreach ($description as $index => $desc) {
         // If this is a string, just pass it along.
         if (is_string($desc)) {
             if ($index === 0) {
                 $desc .= ' ';
             }
             $output[] = $desc;
         } elseif (is_array($desc)) {
             switch (strtolower($desc['name'])) {
                 case 'example':
                     // @todo: Support this!
                     break;
                 case 'internal':
                     // Ignore
                     break;
                 case 'link':
                     if (isset($desc['description'])) {
                         $output[] = '<a href="' . $desc['uri'] . '">' . $desc['description'] . '</a>';
                     } else {
                         $output[] = '<a href="' . $desc['uri'] . '">' . $desc['uri'] . '</a>';
                     }
                     break;
                 case 'see':
                     switch ($desc['entity_hint']) {
                         case 'class':
                             $output[] = '<a href="' . self::getRelativeBasePath($desc['entity'], -1) . '/api-reference/' . self::namespaceAsPath($desc['entity']) . '/index.html' . '">' . $desc['entity'] . '</a>';
                             break;
                         case 'method':
                             list($__class, $__method) = explode('::', $desc['entity']);
                             $output[] = '<a href="' . self::getRelativeBasePath($__class) . '/api-reference/' . self::namespaceAsPath($__class) . '/' . str_replace('()', '', $__method) . '.html' . '">' . $desc['entity'] . '</a>';
                             break;
                         case 'property':
                             list($__class, $__property) = explode('::$', $desc['entity']);
                             $output[] = '<a href="' . self::getRelativeBasePath($__class) . '/api-reference/' . self::namespaceAsPath($__class) . '/properties.html' . '">' . $desc['entity'] . '</a>';
                             break;
                     }
                     break;
             }
         }
     }
     $md = new Markdown();
     return $md->transformMarkdown(implode('', $output));
 }
Example #5
0
/**
 * Notes for a single author -> /authors/:id/notes/
 *
 * @param  int $id author id
 */
function authorNotes($id)
{
    global $app;
    // parameter checking
    if (!is_numeric($id)) {
        $app->getLog()->warn('authorNotes: invalid author id ' . $id);
        $app->halt(400, "Bad parameter");
    }
    $author = $app->calibre->author($id);
    if (is_null($author)) {
        $app->getLog()->debug('authorNotes: author id not found ' . $id);
        $app->notFound();
    }
    $note = $app->bbs->authorNote($id);
    if (!is_null($note)) {
        $author->notes_source = $note->ntext;
    } else {
        $author->notes_source = null;
    }
    if (!empty($author->notes_source)) {
        $markdownParser = new MarkdownExtraParser();
        $author->notes = $markdownParser->transformMarkdown($author->notes_source);
    } else {
        $author->notes = null;
    }
    $app->render('author_notes.html', array('page' => mkPage(getMessageString('author_notes'), 3, 2), 'url' => 'authors/' . $id, 'author' => $author, 'isadmin' => is_admin()));
}
Example #6
0
 /**
  * Retrieve the HTML excerpt for the story.
  *
  * @return string
  */
 public function getExcerpt()
 {
     $markdownExtra = new MarkdownExtraParser();
     $excerpt = $this->getRawExcerpt();
     return $markdownExtra->transformMarkdown($excerpt);
 }
Example #7
0
 /**
  * @param $string
  */
 public function markdown($string)
 {
     $markdownParser = new MarkdownExtraParser();
     echo $markdownParser->transformMarkdown($string);
 }