Matrix does not support markdown format (xxxx.md). These are some settings to work markdown files.
Login on the matrix and move to home directory.
cd ~/
Download cebe/markdown parser
composer require cebe/markdown "~1.0.1"
Create ~/public_html/index.php
<?php
require_once dirname(__FILE__) . '/../vendor/autoload.php';
$path = (isset($_REQUEST['p'])) ? $_REQUEST['p'] : false;
if ($path) {
$file = dirname(__FILE__) . '/' . $path;
if (!file_exists($file)) {
header('HTTP/1.0 403 Forbidden');
exit;
}
} else {
$file = dirname(__FILE__) . '/index.md';
}
$markdown = file_get_contents($file);
$_BASE = (isset($_SERVER['PHP_SELF'])) ? str_replace('/index.php', '', $_SERVER['PHP_SELF']) : '';
//include __DIR__ . '/header.html';
// use github markdown
$parser = new \cebe\markdown\GithubMarkdown();
$parser->html5 = true;
echo $parser->parse($markdown);
//include __DIR__ . '/footer.html';
Create ~/public_html/.htaccess
Options -Indexes
DirectoryIndex index.php index.html index.md
# 404 Not found for .git
RedirectMatch 404 /\.git
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.md)$ /~smlee36/?p=$1 [QSA,L]
(!) Replace 'smlee36' to your matrix id.
Now all settings finish. Create a test file '~/public_html/test.md'
# This is a test markdown file
Open a web browser, go 'http://martrix.senecac.on.ca/~smlee36/test.md'
(!) Replace 'smlee36' to your matrix id.
If you can see the page like this:
Every things works fine.
copy the source and paste to ~/public_html/css/markdown.css
//...
$_BASE = (isset($_SERVER['PHP_SELF'])) ? str_replace('/index.php', '', $_SERVER['PHP_SELF']) : '';
include __DIR__ . '/header.html'; // <-- uncomment this
// use github markdown
$parser = new \cebe\markdown\GithubMarkdown();
$parser->html5 = true;
echo $parser->parse($markdown);
include __DIR__ . '/footer.html'; // <-- uncomment this
//...
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Markdown Page</title>
<link rel="stylesheet" href="<?php echo $_BASE;?>/css/markdown.css">
</head>
<body>
<div id="wrapper">
<hr/>
</div>
</body>
</html>