本文整理汇总了PHP中Markdown类的典型用法代码示例。如果您正苦于以下问题:PHP Markdown类的具体用法?PHP Markdown怎么用?PHP Markdown使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Markdown类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$topics = Topic::all();
$markdown = new Markdown();
$transfer_count = 0;
$convert_count = 0;
foreach ($topics as $topic) {
if (empty($topic->body_original)) {
// store the original data
$topic->body_original = $topic->body;
// convert to markdown
$topic->body = $markdown->convertMarkdownToHtml($topic->body);
$topic->save();
$transfer_count++;
} else {
// convert to markdown
$topic->body = $markdown->convertMarkdownToHtml($topic->body_original);
$topic->save();
$convert_count++;
}
}
$this->info("Transfer old data count: " . $transfer_count);
$this->info("Convert original to body count: " . $convert_count);
$this->info("It's Done, have a good day.");
}
示例2: testDecoding
public function testDecoding()
{
$formatter = new Markdown();
$data = array('name' => 'Joe', 'age' => 21, 'employed' => true, 'body' => "Lorem ipsum dolor\nsit amet");
$raw = file_get_contents(__DIR__ . '/fixtures/joe.md');
$this->assertEquals($data, $formatter->decode($raw));
}
示例3: agregarProducto
/**
* Añade el producto a la base de datos con el nombre, medida, descripcion, rutaimagen, categoria y familia.
*
* @param $nombreprod string.
* @param $precioprod string.
* @param $medidas string.
* @param $descripcionprod string.
* @param $rutaimagen string.
* @param $idcategoria int.
* @param $idfamilia int.
* @return boolean.
*/
public function agregarProducto($nombreprod, $precioprod, $medidas, $descripcionprod, $rutaimagen, $idcategoria, $idfamilia)
{
$Markdown = new Markdown();
$my_html = $Markdown->transform($descripcionprod);
$query = "INSERT INTO producto(nombreprod, precioprod, medidas, descripcionprod, rutaimagen, categoria_idcategoria, categoria_familia_idfamilia)" . "VALUES('{$nombreprod}', '{$precioprod}', '{$medidas}','{$my_html}', '{$rutaimagen}', '{$idcategoria}', '{$idfamilia}');";
$this->logger->getLogger($query);
$result = $this->connection->query($query);
return $result;
}
示例4: testTablesHaveTableClass
public function testTablesHaveTableClass()
{
$parser = new Markdown();
$content = <<<'MARKDOWN'
|Tables|Is|
|------|--|
|OK |? |
MARKDOWN;
$result = $parser->text($content);
$this->assertEquals("<table class=\"table\">\n<thead>\n<tr>\n<th>Tables</th>\n<th>Is</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>OK</td>\n<td>?</td>\n</tr>\n</tbody>\n</table>", $result);
}
示例5: markdown
function markdown($string)
{
#
# Initialize the parser and return the result of its transform method.
#
# Setup static parser variable.
static $parser;
if (!isset($parser)) {
$parser = new Markdown();
}
# Transform text using parser.
return $parser->transform($string);
}
示例6: update
public function update($id)
{
$topic = Topic::findOrFail($id);
$data = Input::only('title', 'body', 'node_id');
$this->authorOrAdminPermissioinRequire($topic->user_id);
$markdown = new Markdown();
$data['body_original'] = $data['body'];
$data['body'] = $markdown->convertMarkdownToHtml($data['body']);
$data['excerpt'] = Topic::makeExcerpt($data['body']);
// Validation
App::make('Phphub\\Forms\\TopicCreationForm')->validate($data);
$topic->update($data);
Flash::success(lang('Operation succeeded.'));
return Redirect::route('topics.show', $topic->id);
}
示例7: _cache_content
/**
* Encodes the content into HTML based on Markdown
*
* @return void
*/
protected function _cache_content()
{
$this->cached_content = Markdown::encode($this->content);
if (preg_match_all('/<p>(.*)<\\/p>/', $this->cached_content, $matches)) {
$this->description = substr(strip_tags($matches[1][0]), 0, 500);
}
}
示例8: getMarkdownParagraph
/**
* Returns a function converting Markdown into HTML but only parsing inline elements.
* @return \Closure A function converting Markdown into HTML but only parsing inline elements.
*/
public function getMarkdownParagraph() : \Closure
{
return function ($value, \Mustache_LambdaHelper $helper) {
$args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]);
return Markdown::processParagraph($args['markdown'], $args['flavor']);
};
}
示例9: previewNoEnclosingPage
/**
* compile markdown to html and render as text
*
* @return Illuminate\View\View
*/
public function previewNoEnclosingPage()
{
$markdown = Markdown::defaultTransform(e(Input::get('data')));
$response = Response::make($markdown);
$response->header('Content-Type', 'text/html');
return $response;
}
示例10: setRenderer
/**
* Sets the renderer for markdown fields to use
* @param {string} $renderer Class Name of an implementation of IMarkdownRenderer
*/
public static function setRenderer($renderer)
{
if (ClassInfo::classImplements($renderer, 'IMarkdownRenderer')) {
self::$renderer = $renderer;
} else {
user_error('The renderer ' . $renderer . ' does not implement IMarkdownRenderer', E_USER_ERROR);
}
}
示例11: get_how_to_use_content
private function get_how_to_use_content($f3)
{
$content = "How to use content.";
$file = F3::instance()->read('help/README.md');
$html = Markdown::instance()->convert($file);
$f3->set('how_to_use_content', $html);
return $content;
}
示例12: get
/**
* Get the given documentation page.
*
* @param string $manual
* @param string $version
* @param string $page
* @return string
*/
public function get($manual, $version, $page)
{
$pageFile = $this->storagePath . '/' . $manual . '/' . $version . '/' . $page . '.md';
if ($this->files->exists($pageFile)) {
return $this->cached("{$manual}.{$version}.{$pageFile}", Markdown::parse($this->files->get($pageFile), $manual . '/' . $version . '/' . dirname($page)));
} else {
App::abort(404);
}
}
示例13: updateExportSettings
private function updateExportSettings()
{
$input = Input::only($this->export_features);
$input['ex_disclaimer_html'] = Markdown::string($input['ex_disclaimer']);
foreach ($input as $key => $value) {
Setting::set($key, $value);
}
return true;
}
示例14: generatePost
/**
* Generate a preview
*
* @param array $input
* @param $user
* @return \Illuminate\View\View
*/
public function generatePost($input, $user)
{
// Generate preview post
$post = $this->postRepo->getEmptyPost();
$post->author = $user;
$post->markdown = $input['content'];
$post->html = \Purifier::clean(\Markdown::text($input['content']));
return $post;
}
示例15: testFacadeRoot
public function testFacadeRoot()
{
$class = get_class(Markdown::getFacadeRoot());
if ('sundown' == Conf::get('markdown')) {
$this->assertEquals('Pochika\\Markdown\\Sundown', $class);
} else {
$this->assertEquals('Pochika\\Markdown\\PHPMarkdownExtra', $class);
}
}