-
Notifications
You must be signed in to change notification settings - Fork 24
/
qa-markdown-viewer.php
43 lines (35 loc) · 951 Bytes
/
qa-markdown-viewer.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
33
34
35
36
37
38
39
40
41
42
43
<?php
/*
Question2Answer Markdown editor plugin
License: http://www.gnu.org/licenses/gpl.html
*/
class qa_markdown_viewer
{
private $plugindir;
public function load_module($directory, $urltoroot)
{
$this->plugindir = $directory;
}
public function calc_quality($content, $format)
{
return $format == 'markdown' ? 1.0 : 0.8;
}
public function get_html($content, $format, $options)
{
if (isset($options['blockwordspreg'])) {
require_once QA_INCLUDE_DIR.'util/string.php';
$content = qa_block_words_replace($content, $options['blockwordspreg']);
}
// include customized Markdown parser
require_once 'MyMarkdown.php';
$md = new MyMarkdown();
$html = $md->parse($content);
return qa_sanitize_html($html, @$options['linksnewwindow']);
}
public function get_text($content, $format, $options)
{
$viewer = qa_load_module('viewer', '');
$text = $viewer->get_text($content, 'html', array());
return $text;
}
}