-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
35 lines (30 loc) · 1.09 KB
/
index.php
File metadata and controls
35 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php namespace x\markdown;
function page__content($content) {
$type = $this->type();
if ('Markdown' !== $type && 'text/markdown' !== $type) {
return $content;
}
$content = \strtr(\From::markdown($content) ?? "", [' />' => '>']);
return "" !== $content ? $content : null;
}
function page__description($description) {
return \fire(__NAMESPACE__ . "\\page__title", [$description], $this);
}
function page__title($title) {
$type = $this->type();
if ('Markdown' !== $type && 'text/markdown' !== $type) {
return $title;
}
$title = \strtr(\From::markdown($title, false) ?? "", [' />' => '>']);
return "" !== $title ? $title : null;
}
function page__type($type) {
if (false !== \strpos(',markdown,md,mkd,', ',' . ($this->_x() ?? \P) . ',')) {
return 'Markdown';
}
return $type;
}
\Hook::set('page.content', __NAMESPACE__ . "\\page__content", 2);
\Hook::set('page.description', __NAMESPACE__ . "\\page__description", 2);
\Hook::set('page.title', __NAMESPACE__ . "\\page__title", 2);
\Hook::set('page.type', __NAMESPACE__ . "\\page__type", 0);