1. Go to this page and download the library: Download phpsoftbox/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/ */
phpsoftbox / markdown example snippets
use PhpSoftBox\Markdown\MarkdownRenderer;
$document = new MarkdownRenderer()->render(<<<'MD'
---
title: Установка
---
## Быстрый старт
Текст документации.
MD);
echo $document->html();
use PhpSoftBox\Markdown\MarkdownRenderOptions;
$document = $renderer->render($source, new MarkdownRenderOptions(
tocMinHeadingLevel: 2,
tocMaxHeadingLevel: 3,
));
use PhpSoftBox\Markdown\Contracts\MarkdownLinkResolverInterface;
use PhpSoftBox\Markdown\MarkdownRenderContext;
use PhpSoftBox\Markdown\MarkdownResolvedAsset;
use PhpSoftBox\Markdown\MarkdownResolvedLink;
final class AppMarkdownLinkResolver implements MarkdownLinkResolverInterface
{
public function resolveLink(string $target, MarkdownRenderContext $context): MarkdownResolvedLink
{
return MarkdownResolvedLink::resolved('/content/' . trim($target, './'));
}
public function resolveAsset(string $target, MarkdownRenderContext $context): MarkdownResolvedAsset
{
return MarkdownResolvedAsset::resolved('/assets/content/' . trim($target, './'));
}
}
$document = $renderer->render($source, new MarkdownRenderOptions(
basePath: '/content',
currentDocumentPath: 'articles/install.md',
linkResolver: new AppMarkdownLinkResolver(),
));
title="src/Action.php"
echo 'ok';
echo 'ok';
use PhpSoftBox\Markdown\MarkdownHtmlPolicy;
use PhpSoftBox\Markdown\MarkdownRenderOptions;
$document = $renderer->render($source, new MarkdownRenderOptions(
htmlPolicy: MarkdownHtmlPolicy::Escape,
));
$document = $renderer->render($source, new MarkdownRenderOptions(
externalLinkTarget: '_blank',
externalLinksNoFollow: true,
));