forked from koreapyj/php-namumark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoader.php
32 lines (27 loc) · 1.07 KB
/
Loader.php
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
<?php
namespace PressDo\app\Helpers\Mark;
class Loader
{
static function loadMarkUp(string $content, array $options): array|string{
require_once 'Namumark.php';
require_once 'HTMLRenderer.php';
$wEngine = new Namumark();
$wEngine->title = $options['title'];
$wEngine->inThread = $options['thread'];
$wEngine->db = true;
$content = str_replace("\r\n", "\n", $content);
$wHtml = $wEngine->toHtml($content);
$wLink = [
'link' => array_unique($wEngine->links['link']),
'redirect' => array_unique($wEngine->links['redirect']),
'file' => array_unique($wEngine->links['file']),
'include' => array_unique($wEngine->links['include']),
'category' => $wEngine->links['category'],
];
// toHtml을 호출하면 HTML 페이지가 생성됩니다.
if ($options['thread'])
return $wHtml;
else
return ['html' => $wHtml, 'categories' => $wEngine->links['category'], 'links' => $wLink];
}
}