Hi iainhallam
I am certainly not a specialist for PHP or plugins, but I still try again and again 😂
Using the following simple code:
<?php
/**
* DokuWiki Plugin sample (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*/
class syntax_plugin_sample extends \dokuwiki\Extension\SyntaxPlugin
{
/** @inheritDoc */
public function getType()
{
return 'substition';
}
/** @inheritDoc */
public function getPType()
{
return 'normal';
}
/** @inheritDoc */
public function getSort()
{
return 400;
}
function accepts($mode) {
if ($mode == substr(get_class($this), 7)) return true;
return parent::accepts($mode);
}
/**
* @return array Things that may be inside the syntax
*/
function getAllowedTypes() {
return array('container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs');
}
/** @inheritDoc */
public function connectTo($mode)
{
// $this->Lexer->addSpecialPattern('<FIXME>', $mode, 'plugin_sample');
$this->Lexer->addEntryPattern('<sample>(?=.*?</sample>)',$mode, 'plugin_sample');
}
// /** @inheritDoc */
public function postConnect()
{
$this->Lexer->addExitPattern('</sample>', 'plugin_sample');
}
/** @inheritDoc */
public function handle($match, $state, $pos, Doku_Handler $handler)
{
$data = [];
switch ($state) {
case DOKU_LEXER_ENTER :
return array($state,$data);
case DOKU_LEXER_UNMATCHED :
return array ($state,$match);
case DOKU_LEXER_EXIT :
return array($state,$data);
}
return array();
}
/** @inheritDoc */
public function render($mode, Doku_Renderer $renderer, $data)
{
if ($mode !== 'xhtml') {
return false;
}
list($state,$indata) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
$renderer->doc .= '<div class="dw_nested_sample">'. DOKU_LF;
break;
case DOKU_LEXER_UNMATCHED :
$renderer->doc .= $renderer->cdata($indata);
break;
case DOKU_LEXER_EXIT :
$renderer->doc .= '</div>'. DOKU_LF;
break;
}
return true;
}
}
I have achieved the following:
===== Nested Syntax =====
<sample>
Sample 1 --BEGIN-- \\
<sample>
Sample 2 ---BEGIN--- \\
Sample 2 ---END--- \\
<sample>
Sample 1 --END-- \\
</sample>
I can't say if all of this is correct. Unfortunately, I know too little about it. But the basic idea should work like this.
Edit: Ok sorry, I think I misunderstood your problem.
I did this with dwtimeline so that I used a second, inner tag. So I had one for the general stuff and the inner one for the milestones. I am a beginner, maybe someone with more experience can help better.