-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCriticMarkup.php
38 lines (36 loc) · 1.16 KB
/
CriticMarkup.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
<?php
/**
* CriticMarkup Plugin
*
* Renders CriticMarkup to HTML
*
* @author Markus Hermann
* @link https://github.com/hermannmarkus/Pico-CriticMarkup-Plugin
* @license http://opensource.org/licenses/MIT The MIT License
* @version 1.0
*/
class CriticMarkup extends AbstractPicoPlugin {
/**
* API version used by this plugin
*
* @var int
*/
const API_VERSION = 2;
/**
* Triggered after Pico has prepared the raw file contents for parsing
*
* @see DummyPlugin::onContentParsing()
* @see Pico::parseFileContent()
* @see DummyPlugin::onContentParsed()
*
* @param string &$markdown Markdown contents of the requested page
*
* @return void
*/
public function onContentPrepared(&$markdown) {
$markdown = preg_replace('/(\{\+\+)(.*)(\+\+\})/m', '<ins>\2</ins>', $markdown);
$markdown = preg_replace('/(\{\-\-)(.*)(\-\-\})/m', '<del>\2</del>', $markdown);
$markdown = preg_replace('/(\{>>)(.*)(<<\})/m', '<span class="critic comment">\2</span>', $markdown);
$markdown = preg_replace('/(\{~~)(.*)(~>)(.*)(~~\})/m', '<del>\2</del><ins>\4</ins>', $markdown);
}
}