Skip to content

Commit 7e025e6

Browse files
author
Mizunashi Mana
committed
Add markdown_default
1 parent 938cb40 commit 7e025e6

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

conf/default.php

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
$conf['debug'] = 0;
44
$conf['flavor'] = 'github-flavored';
5+
$conf['markdown_default'] = 0;

conf/metadata.php

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
'markdown-extra',
1313
],
1414
];
15+
$meta['markdown_default'] = [
16+
'onoff',
17+
];

lang/en/settings.php

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
$lang['debug'] = 'Display additional debug information';
44
$lang['flavor'] = 'Markdown flavor';
5+
$lang['markdown_default'] = 'Make Markdown to default DokuWiki syntax';

lang/ja/settings.php

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
$lang['debug'] = '追加のデバッグ情報を表示する';
44
$lang['flavor'] = 'Markdown記法';
5+
$lang['markdown_default'] = 'Markdown を DokuWiki のデフォルト構文にする';

syntax.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,33 @@ public function getPluginName() {
3434
}
3535

3636
public function connectTo($mode) {
37-
$this->Lexer->addEntryPattern('<markdown>(?=.*</markdown>)', $mode, 'plugin_' . $this->getPluginName());
37+
if ($this->getConf('markdown_default')) {
38+
$this->Lexer->addEntryPattern('\\A.', $mode, 'plugin_' . $this->getPluginName());
39+
} else {
40+
$this->Lexer->addEntryPattern('<markdown>(?=.*</markdown>)', $mode, 'plugin_' . $this->getPluginName());
41+
}
3842
}
3943

4044
public function postConnect() {
41-
$this->Lexer->addExitPattern('</markdown>', 'plugin_' . $this->getPluginName());
45+
if ($this->getConf('markdown_default')) {
46+
$this->Lexer->addExitPattern('\\z', 'plugin_' . $this->getPluginName());
47+
} else {
48+
$this->Lexer->addExitPattern('</markdown>', 'plugin_' . $this->getPluginName());
49+
}
4250
}
4351

4452
public function handle($match, $state, $pos, Doku_Handler $handler) {
4553
switch ($state) {
4654
case DOKU_LEXER_UNMATCHED:
55+
$new_pos = $pos;
56+
if (!$this->getConf('markdown_default')) {
57+
$new_pos = $new_pos - strlen('<markdown>');
58+
}
59+
4760
return [
4861
'render' => true,
4962
'match' => $match,
50-
'pos' => $pos - strlen('<markdown>'),
63+
'pos' => $new_pos,
5164
];
5265
default:
5366
return [

0 commit comments

Comments
 (0)