Commit 7a4cde1c authored by Wataru Noguchi's avatar Wataru Noguchi ✍🏻

Implement GitLab snippet embed.

parent 77af0d48
......@@ -18,7 +18,7 @@ class syntax_plugin_gitlabsnippet_gitlabsnippetsyntax extends DokuWiki_Syntax_Pl
*/
public function getType()
{
return 'FIXME: container|baseonly|formatting|substition|protected|disabled|paragraphs';
return 'substition';
}
/**
......@@ -26,7 +26,8 @@ class syntax_plugin_gitlabsnippet_gitlabsnippetsyntax extends DokuWiki_Syntax_Pl
*/
public function getPType()
{
return 'FIXME: normal|block|stack';
return 'block';
//return 'FIXME: normal|block|stack';
}
/**
......@@ -34,9 +35,11 @@ class syntax_plugin_gitlabsnippet_gitlabsnippetsyntax extends DokuWiki_Syntax_Pl
*/
public function getSort()
{
return FIXME;
return 32;
}
//public function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
/**
* Connect lookup pattern to lexer.
*
......@@ -44,7 +47,7 @@ class syntax_plugin_gitlabsnippet_gitlabsnippetsyntax extends DokuWiki_Syntax_Pl
*/
public function connectTo($mode)
{
$this->Lexer->addSpecialPattern('<FIXME>', $mode, 'plugin_gitlabsnippet_gitlabsnippetsyntax');
$this->Lexer->addSpecialPattern('\[gitlab-snippet [^\]]+\]', $mode, 'plugin_gitlabsnippet_gitlabsnippetsyntax');
// $this->Lexer->addEntryPattern('<FIXME>', $mode, 'plugin_gitlabsnippet_gitlabsnippetsyntax');
}
......@@ -65,7 +68,16 @@ class syntax_plugin_gitlabsnippet_gitlabsnippetsyntax extends DokuWiki_Syntax_Pl
*/
public function handle($match, $state, $pos, Doku_Handler $handler)
{
$data = array();
$snippetData = explode(" ", $match);
$snippetData = $snippetData[1];
$snippetData = substr($snippetData, 0, -1);
if (strpos($snippetData, '.js') === false) {
$snippetData .= '.js';
}
$data = array($snippetData);
return $data;
}
......@@ -85,6 +97,10 @@ class syntax_plugin_gitlabsnippet_gitlabsnippetsyntax extends DokuWiki_Syntax_Pl
return false;
}
$snippetData = $data[0];
$renderer->doc .= '<script src="' . $snippetData . '"></script>';
return true;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment