Skip to content

Commit 77c8926

Browse files
committed
home page now displays formatted README.md
1 parent ee7b922 commit 77c8926

File tree

3 files changed

+85
-4
lines changed

3 files changed

+85
-4
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
],
1717
"require": {
1818
"scrivo/highlight.php": "^9.0",
19-
"silex/silex": "^2.1"
19+
"silex/silex": "^2.1",
20+
"league/commonmark": "^0.15.4"
2021
},
2122
"autoload": {
2223
"psr-4": {

composer.lock

Lines changed: 70 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/index.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
<?php
22
require_once __DIR__ . '/../vendor/autoload.php';
33

4+
use League\CommonMark\CommonMarkConverter;
5+
46
$app = new Silex\Application();
57
$fiddle = new \PhpFiddler\Fiddle();
68

7-
$app->get('/', function() {
8-
return 'Hello world';
9+
$app->get('/', function() use ($fiddle) {
10+
ob_start();
11+
$fiddle->start();
12+
$converter = new CommonMarkConverter;
13+
echo '<div class="readme">';
14+
echo $converter->convertToHtml(file_get_contents(__DIR__ . '/../README.md'));
15+
echo '</div>';
16+
$fiddle->end();
17+
$body = ob_get_clean();
18+
19+
return $body;
920
});
1021

1122
$app->get('/examples/{name}', function($name) use ($app, $fiddle) {

0 commit comments

Comments
 (0)