This change brings this library's autoloading up to modern standards in the larger PHP community and uses methods recommended by the PHP dependency manager, composer. From PSR-0 http://www.php-fig.org/psr/psr-0/ > As of 2014-10-21 PSR-0 has been marked as deprecated. PSR-4 is now > recommended as an alternative. PSR-4: http://www.php-fig.org/psr/psr-4/ From composer https://getcomposer.org/doc/04-schema.md#autoload > PSR-4 is the recommended way since it offers greater ease of use (no > need to regenerate the autoloader when you add classes).
31 lines
721 B
PHP
31 lines
721 B
PHP
<?php
|
|
|
|
// This file passes the content of the Readme.md file in the same directory
|
|
// through the Markdown filter. You can adapt this sample code in any way
|
|
// you like.
|
|
|
|
// Install PSR-4-compatible class autoloader
|
|
spl_autoload_register(function($class){
|
|
require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
|
|
});
|
|
|
|
// Get Markdown class
|
|
use Michelf\Markdown;
|
|
|
|
// Read file and pass content through the Markdown parser
|
|
$text = file_get_contents('Readme.md');
|
|
$html = Markdown::defaultTransform($text);
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>PHP Markdown Lib - Readme</title>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
// Put HTML content in the document
|
|
echo $html;
|
|
?>
|
|
</body>
|
|
</html>
|