PHP code example of montyxrizzo / yii2-markdown

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

    

montyxrizzo / yii2-markdown example snippets


'modules' = [
	/* other modules */
	'markdown' => [
		'class' => 'kartik\markdown\Module',
	]
];

'modules' = [
	'markdown' => [
		// the module class
		'class' => 'kartik\markdown\Module',
		
		// the controller action route used for markdown editor preview
		'previewAction' => '/markdown/parse/preview',
		
		// the list of custom conversion patterns for post processing
		'customConversion' => [
			'<table>' => '<table class="table table-bordered table-striped">'
		],
		
		// whether to use PHP SmartyPantsTypographer to process Markdown output
		'smartyPants' => true
	]
	/* other modules */
];

use kartik\markdown\Markdown;

// default call
echo Markdown::convert($content);

// with custom post processing
echo Markdown::convert($content, ['custom' => [
	'<h1>' => '<h1 class="custom-h1>',
	'<h2>' => '<h1 class="custom-h2>',
]]);

// add this in your view
use kartik\markdown\MarkdownEditor;

// usage with model
echo MarkdownEditor::widget([
	'model' => $model, 
	'attribute' => 'markdown',
]);

// usage without model
echo MarkdownEditor::widget([
	'name' => 'markdown', 
	'value' => $value,
]);

$ php composer.phar