use tildeverse/wiki external dep
This commit is contained in:
parent
443268fd1d
commit
19db11d958
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"mnapoli/front-yaml": "^1.6",
|
"tildeverse/wiki": "dev-master"
|
||||||
"erusev/parsedown-extra": "^0.7.1"
|
|
||||||
},
|
},
|
||||||
"autoload": {
|
"repositories": [
|
||||||
"psr-4": {
|
{
|
||||||
"Wiki\\": "src/"
|
"type": "vcs",
|
||||||
|
"url": "https://tildegit.org/ben/tildewiki"
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "db7c98dc793b27a7aff27ee1d448fa42",
|
"content-hash": "3ab3df15c4e40417f427b37691e83088",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "erusev/parsedown",
|
"name": "erusev/parsedown",
|
||||||
|
@ -247,12 +247,44 @@
|
||||||
"description": "Symfony Yaml Component",
|
"description": "Symfony Yaml Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2019-04-06T14:04:46+00:00"
|
"time": "2019-04-06T14:04:46+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tildeverse/wiki",
|
||||||
|
"version": "dev-master",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://tildegit.org/ben/tildewiki",
|
||||||
|
"reference": "751eb64c383cb7c6ec643eaf683b88aa1de351ea"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"erusev/parsedown-extra": "^0.7.1",
|
||||||
|
"mnapoli/front-yaml": "^1.6"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tildeverse\\Wiki\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": [
|
||||||
|
"GPLv3"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Ben Harris",
|
||||||
|
"email": "ben@tilde.team"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "parsedown extensions for tilde wikis",
|
||||||
|
"time": "2019-07-03T05:06:34+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": {
|
||||||
|
"tildeverse/wiki": 20
|
||||||
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
include 'header.php';
|
include 'header.php';
|
||||||
require __DIR__.'/vendor/autoload.php';
|
require __DIR__.'/vendor/autoload.php';
|
||||||
$parser = Wiki\MDParser::factory();
|
$parser = Tildeverse\Wiki\Parser::factory();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?php
|
|
||||||
namespace Wiki;
|
|
||||||
|
|
||||||
use Mni\FrontYAML;
|
|
||||||
|
|
||||||
class MDParser implements FrontYAML\Markdown\MarkdownParser {
|
|
||||||
public function __construct() {
|
|
||||||
$this->mdparser = new WikiParsedown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function parse($markdown) {
|
|
||||||
return $this->mdparser->text($markdown);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function factory() {
|
|
||||||
return new FrontYAML\Parser(null, new MDParser());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WikiParsedown extends \ParsedownExtra {
|
|
||||||
protected function blockHeader($line) {
|
|
||||||
$header = parent::blockHeader($line);
|
|
||||||
|
|
||||||
if (!isset($header)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = preg_replace('/[^a-z0-9]/', '-', strtolower($header['element']['text']));
|
|
||||||
$header['element']['attributes']['id'] = $id;
|
|
||||||
|
|
||||||
$header['element']['text'] =
|
|
||||||
'<small><a class="text-muted" href="#' . $id . '"><i class="fa fa-link"></i></a></small> '
|
|
||||||
. $header['element']['text'];
|
|
||||||
|
|
||||||
return $header;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function blockTable($line, array $block = null) {
|
|
||||||
$table = parent::blockTable($line, $block);
|
|
||||||
|
|
||||||
if (!isset($table)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$table['element']['attributes']['class'] = "table table-striped";
|
|
||||||
|
|
||||||
return $table;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ $additional_head = "
|
||||||
<meta property='og:site_name' content='tilde.team wiki'>
|
<meta property='og:site_name' content='tilde.team wiki'>
|
||||||
";
|
";
|
||||||
|
|
||||||
$parser = Wiki\MDParser::factory();
|
$parser = Tildeverse\Wiki\Parser::factory();
|
||||||
|
|
||||||
|
|
||||||
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
|
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
|
||||||
|
|
Loading…
Reference in New Issue