PHP code example of semmelsamu / commonmark-extensions
1. Go to this page and download the library: Download semmelsamu/commonmark-extensions 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/ */
semmelsamu / commonmark-extensions example snippets
use League\CommonMark\Environment\Environment;
// Create the converter environment:
$environment = new Environment($config);
// Add the extensions you wish:
$environment->addExtension(new CommonmarkExtension());
// Go forth and convert you some Markdown!
$converter = new MarkdownConverter($environment);
use Semmelsamu\CommonmarkExtensions\Callout\CalloutExtension;
/**
* Don't forget to also add this renderer to your environment:
* `$environment->addRenderer(new WikilinkEmbedImageRenderer())`
*/
class WikilinkEmbedImageRenderer implements NodeRendererInterface
{
public function render(Node $node, ChildNodeRendererInterface $childRenderer)
{
Embed::assertInstanceOf($node);
if (!preg_match('/\.(jpg|jpeg|png|gif)$/i', $src)) {
// Not an image, let this embed be handled by some other renderer
return null;
}
$attributes = ['href' => $node->src];
if ($node->caption) {
$attributes['alt'] = $node->caption;
}
return new HtmlElement(
'image',
$attributes
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.