PHP code example of yiipress / markdown

1. Go to this page and download the library: Download yiipress/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/ */

    

yiipress / markdown example snippets


use YiiPress\Markdown\MarkdownOptions;
use YiiPress\Markdown\MarkdownRenderer;

$renderer = new MarkdownRenderer(new MarkdownOptions(
    tables: true,
    tasklists: true,
    htmlBlocks: true,
    htmlSpans: true,
));

echo $renderer->render("# Hello");

$renderer = new MarkdownRenderer(new MarkdownOptions(
    htmlBlocks: false,
    htmlSpans: false,
));

$renderer = new MarkdownRenderer(new MarkdownOptions(
    latexMath: true,
    wikilinks: true,
    spoilers: true,
    superscripts: true,
    subscripts: true,
    highlight: true,
));

use YiiPress\Markdown\HtmlFlag;
use YiiPress\Markdown\MarkdownOptions;
use YiiPress\Markdown\MarkdownRenderer;

$renderer = new MarkdownRenderer(new MarkdownOptions(
    rendererFlags: HtmlFlag::XHTML | HtmlFlag::VERBATIM_ENTITIES,
));

use YiiPress\Markdown\Flag;
use YiiPress\Markdown\MarkdownOptions;

$options = new MarkdownOptions(htmlBlocks: false, htmlSpans: false);
$parserFlags = $options->toParserFlags();

if (($parserFlags & Flag::NO_HTML) === Flag::NO_HTML) {
    // Raw HTML blocks and spans are disabled.
}

use YiiPress\Markdown\Dialect;

$githubFlags = Dialect::GITHUB;