summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/markdowku/syntax/anchorsinline.php
diff options
context:
space:
mode:
Diffstat (limited to 'platform/www/lib/plugins/markdowku/syntax/anchorsinline.php')
-rw-r--r--platform/www/lib/plugins/markdowku/syntax/anchorsinline.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/platform/www/lib/plugins/markdowku/syntax/anchorsinline.php b/platform/www/lib/plugins/markdowku/syntax/anchorsinline.php
new file mode 100644
index 0000000..b16f2b4
--- /dev/null
+++ b/platform/www/lib/plugins/markdowku/syntax/anchorsinline.php
@@ -0,0 +1,46 @@
+<?php
+/*
+ * Inline links [name](target "title")
+ */
+
+if(!defined('DOKU_INC')) die();
+if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+require_once(DOKU_PLUGIN.'syntax.php');
+
+class syntax_plugin_markdowku_anchorsinline extends DokuWiki_Syntax_Plugin {
+
+ function getType() { return 'substition'; }
+ function getPType() { return 'normal'; }
+ function getSort() { return 102; }
+
+ function connectTo($mode) {
+ $this->nested_brackets_re =
+ str_repeat('(?>[^\[\]]+|\[', 6).
+ str_repeat('\])*', 6);
+ $this->Lexer->addSpecialPattern(
+ '\['.$this->nested_brackets_re.'\]\([ \t]*<?.+?>?[ \t]*(?:[\'"].*?[\'"])?\)',
+ $mode,
+ 'plugin_markdowku_anchorsinline'
+ );
+ }
+
+ function handle($match, $state, $pos, Doku_Handler $handler) {
+ if ($state == DOKU_LEXER_SPECIAL) {
+ $text = preg_match(
+ '/^\[('.$this->nested_brackets_re.')\]\([ \t]*<?(.+?)>?[ \t]*(?:[\'"](.*?)[\'"])?[ \t]*?\)$/',
+ $match,
+ $matches);
+ $target = $matches[2] == '' ? $matches[3] : $matches[2];
+ $title = $matches[1];
+
+ $target = preg_replace('/^mailto:/', '', $target);
+ $handler->internallink($target.'|'.$title, $state, $pos);
+ }
+ return true;
+ }
+
+ function render($mode, Doku_Renderer $renderer, $data) {
+ return true;
+ }
+}
+//Setup VIM: ex: et ts=4 enc=utf-8 :