PHP code example of alto / markdown
1. Go to this page and download the library: Download alto/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/ */
alto / markdown example snippets
use Alto\Markdown\Markdown;
$markdown = "# Installation\n\nRun `composer install`.\n";
$html = Markdown::github()->toHtml($markdown);
$label = Markdown::github()->toInlineHtml('Install **Alto**');
use Alto\Markdown\Markdown;
$document = Markdown::github()->fromString(
"# Guide\n\nRead the [documentation](https://example.com).\n\n"
."## Install\n\nOld instructions.\n",
);
$title = $document->title()?->text();
$linkCount = $document->links()->count();
$document->section('Install')->replaceBody("Run Composer.\n");
$markdown = $document->toMarkdown();
$html = $document->toHtml();
use Alto\Markdown\Lint\LintConfig;
use Alto\Markdown\Markdown;
use Alto\Markdown\Operation\SaveOptions;
$file = Markdown::github()->open('README.md');
$config = LintConfig::recommended();
$report = $file->lint($config);
$file->fix($config);
$file->format();
if ($file->hasChanges()) {
echo $file->diff()->toUnifiedString();
$file->save(new SaveOptions(compareBeforeWrite: true));
}