1. Go to this page and download the library: Download ntzwbr/markdown library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ntzwbr / markdown example snippets
// original markdown and parse full text
$parser = new \cebe\markdown\Markdown();
$parser->parse($markdown);
// use github markdown
$parser = new \cebe\markdown\GithubMarkdown();
$parser->parse($markdown);
// use markdown extra
$parser = new \cebe\markdown\MarkdownExtra();
$parser->parse($markdown);
// use markdown extra with bootstrap-grid
$parser = new \cebe\markdown\BootstrapMarkdown();
$parser->parse($markdown);
// parse only inline elements (useful for one-line descriptions)
$parser = new \cebe\markdown\GithubMarkdown();
$parser->parseParagraph($markdown);
class MyMarkdown extends \cebe\markdown\Markdown
{
protected function identifyLine($lines, $current)
{
// if a line starts with at least 3 backticks it is identified as a fenced code block
if (strncmp($lines[$current], '
protected function consumeFencedCode($lines, $current)
{
// create block array
$block = [
'type' => 'fencedCode',
'content' => [],
];
$line = rtrim($lines[$current]);
// detect language and fence length (can be more than 3 backticks)
$fence = substr($line, 0, $pos = strrpos($line, '`') + 1);
$language = substr($line, $pos);
if (!empty($language)) {
$block['language'] = $language;
}
// consume all lines until
class MyMarkdown extends \cebe\markdown\Markdown
{
protected function inlineMarkers()
{
$markers = [
'~~' => 'parseStrike',
];
// merge new markers with existing ones from parent class
return array_merge(parent::inlineMarkers(), $markers);
}
protected function parseStrike($markdown)
{
// check whether the marker really represents a strikethrough (i.e. there is a closing ~~)
if (preg_match('/^~~(.+?)~~/', $markdown, $matches)) {
return [
// return the parsed tag with its content and call `parseInline()` to allow
// other inline markdown elements inside this tag
'<del>' . $this->parseInline($matches[1]) . '</del>',
// return the offset of the parsed text
strlen($matches[0])
];
}
// in case we did not find a closing ~~ we just return the marker and skip 2 characters
return [$markdown[0] . $markdown[1], 2];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.