forked from svivian/q2a-markdown-editor
-
Notifications
You must be signed in to change notification settings - Fork 2
/
qa-markdown-viewer.php
42 lines (34 loc) · 893 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
<?php
/*
Question2Answer Markdown editor plugin
License: http://www.gnu.org/licenses/gpl.html
*/
class qa_markdown_viewer
{
private $plugindir;
function load_module($directory, $urltoroot)
{
$this->plugindir = $directory;
}
function calc_quality($content, $format)
{
return $format == 'markdown' ? 1.0 : 0.8;
}
function get_html($content, $format, $options)
{
if ( isset( $options['blockwordspreg'] ) )
{
require_once QA_INCLUDE_DIR.'qa-util-string.php';
$content = qa_block_words_replace( $content, $options['blockwordspreg'] );
}
require_once $this->plugindir . 'inc.markdown.php';
$html = Markdown( $content );
return qa_sanitize_html($html, @$options['linksnewwindow']);
}
function get_text($content, $format, $options)
{
$viewer = qa_load_module( 'viewer', '' );
$text = $viewer->get_text( $content, 'html', array() );
return $text;
}
}