Adding wrap version 2023-08-13 (63b6c01).
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
82229a3e1e
commit
d25794905f
112 changed files with 4620 additions and 0 deletions
35
plugins/55/wrap/syntax/closesection.php
Normal file
35
plugins/55/wrap/syntax/closesection.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Section close helper of the Wrap Plugin
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Michael Hamann <michael@content-space.de>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_closesection extends DokuWiki_Syntax_Plugin {
|
||||
|
||||
function getType(){ return 'substition';}
|
||||
function getPType(){ return 'block';}
|
||||
function getSort(){ return 195; }
|
||||
|
||||
/**
|
||||
* Dummy handler, this syntax part has no syntax but is directly added to the instructions by the div syntax
|
||||
*/
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output
|
||||
*/
|
||||
function render($format, Doku_Renderer $renderer, $data) {
|
||||
if($format == 'xhtml'){
|
||||
/** @var Doku_Renderer_xhtml $renderer */
|
||||
$renderer->finishSectionEdit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
134
plugins/55/wrap/syntax/div.php
Normal file
134
plugins/55/wrap/syntax/div.php
Normal file
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
/**
|
||||
* Div Syntax Component of the Wrap Plugin
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Anika Henke <anika@selfthinker.org>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_div extends DokuWiki_Syntax_Plugin {
|
||||
protected $special_pattern = '<div\b[^>\r\n]*?/>';
|
||||
protected $entry_pattern = '<div\b.*?>(?=.*?</div>)';
|
||||
protected $exit_pattern = '</div>';
|
||||
|
||||
function getType(){ return 'formatting';}
|
||||
function getAllowedTypes() { return array('container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); }
|
||||
function getPType(){ return 'stack';}
|
||||
function getSort(){ return 195; }
|
||||
// override default accepts() method to allow nesting - ie, to get the plugin accepts its own entry syntax
|
||||
function accepts($mode) {
|
||||
if ($mode == substr(get_class($this), 7)) return true;
|
||||
return parent::accepts($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect pattern to lexer
|
||||
*/
|
||||
function connectTo($mode) {
|
||||
$this->Lexer->addSpecialPattern($this->special_pattern,$mode,'plugin_wrap_'.$this->getPluginComponent());
|
||||
$this->Lexer->addEntryPattern($this->entry_pattern,$mode,'plugin_wrap_'.$this->getPluginComponent());
|
||||
}
|
||||
|
||||
function postConnect() {
|
||||
$this->Lexer->addExitPattern($this->exit_pattern, 'plugin_wrap_'.$this->getPluginComponent());
|
||||
$this->Lexer->addPattern('[ \t]*={2,}[^\n]+={2,}[ \t]*(?=\n)', 'plugin_wrap_'.$this->getPluginComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the match
|
||||
*/
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
global $conf;
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER:
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
$data = strtolower(trim(substr($match,strpos($match,' '),-1)," \t\n/"));
|
||||
return array($state, $data);
|
||||
|
||||
case DOKU_LEXER_UNMATCHED:
|
||||
$handler->addCall('cdata', array($match), $pos);
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_MATCHED:
|
||||
// we have a == header ==, use the core header() renderer
|
||||
// (copied from core header() in inc/parser/handler.php)
|
||||
$title = trim($match);
|
||||
$level = 7 - strspn($title,'=');
|
||||
if($level < 1) $level = 1;
|
||||
$title = trim($title,'=');
|
||||
$title = trim($title);
|
||||
|
||||
$handler->addCall('header',array($title,$level,$pos), $pos);
|
||||
// close the section edit the header could open
|
||||
if ($title && $level <= $conf['maxseclevel']) {
|
||||
$handler->addPluginCall('wrap_closesection', array(), DOKU_LEXER_SPECIAL, $pos, '');
|
||||
}
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_EXIT:
|
||||
return array($state, '');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output
|
||||
*/
|
||||
function render($format, Doku_Renderer $renderer, $indata) {
|
||||
static $type_stack = array ();
|
||||
|
||||
if (empty($indata)) return false;
|
||||
list($state, $data) = $indata;
|
||||
|
||||
if($format == 'xhtml'){
|
||||
/** @var Doku_Renderer_xhtml $renderer */
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER:
|
||||
$sectionEditStartData = ['target' => 'plugin_wrap_start', 'hid' => ''];
|
||||
$sectionEditEndData = ['target' =>'plugin_wrap_end', 'hid' => ''];
|
||||
if (!defined('SEC_EDIT_PATTERN')) {
|
||||
// backwards-compatibility for Frusterick Manners (2017-02-19)
|
||||
$sectionEditStartData = 'plugin_wrap_start';
|
||||
$sectionEditEndData = 'plugin_wrap_end';
|
||||
}
|
||||
// add a section edit right at the beginning of the wrap output
|
||||
$renderer->startSectionEdit(0, $sectionEditStartData);
|
||||
$renderer->finishSectionEdit();
|
||||
// add a section edit for the end of the wrap output. This prevents the renderer
|
||||
// from closing the last section edit so the next section button after the wrap syntax will
|
||||
// include the whole wrap syntax
|
||||
$renderer->startSectionEdit(0, $sectionEditEndData);
|
||||
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
$wrap = $this->loadHelper('wrap');
|
||||
$attr = $wrap->buildAttributes($data, 'plugin_wrap');
|
||||
|
||||
$renderer->doc .= '<div'.$attr.'>';
|
||||
if ($state == DOKU_LEXER_SPECIAL) $renderer->doc .= '</div>';
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_EXIT:
|
||||
$renderer->doc .= '</div>';
|
||||
$renderer->finishSectionEdit();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if($format == 'odt'){
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER:
|
||||
$wrap = plugin_load('helper', 'wrap');
|
||||
array_push ($type_stack, $wrap->renderODTElementOpen($renderer, 'div', $data));
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_EXIT:
|
||||
$element = array_pop ($type_stack);
|
||||
$wrap = plugin_load('helper', 'wrap');
|
||||
$wrap->renderODTElementClose ($renderer, $element);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
19
plugins/55/wrap/syntax/divblock.php
Normal file
19
plugins/55/wrap/syntax/divblock.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Alternate div syntax component for the wrap plugin
|
||||
*
|
||||
* Defines <block> ... </block> syntax
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Anika Henke <anika@selfthinker.org>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_divblock extends syntax_plugin_wrap_div {
|
||||
|
||||
protected $special_pattern = '<block\b[^>\r\n]*?/>';
|
||||
protected $entry_pattern = '<block\b.*?>(?=.*?</block>)';
|
||||
protected $exit_pattern = '</block>';
|
||||
|
||||
|
||||
}
|
||||
|
18
plugins/55/wrap/syntax/divwrap.php
Normal file
18
plugins/55/wrap/syntax/divwrap.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Alternate div syntax component for the wrap plugin
|
||||
*
|
||||
* Defines <WRAP> ... </WRAP> syntax
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Anika Henke <anika@selfthinker.org>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_divwrap extends syntax_plugin_wrap_div {
|
||||
|
||||
protected $special_pattern = '<WRAP\b[^>\r\n]*?/>';
|
||||
protected $entry_pattern = '<WRAP\b.*?>(?=.*?</WRAP>)';
|
||||
protected $exit_pattern = '</WRAP>';
|
||||
|
||||
}
|
||||
|
100
plugins/55/wrap/syntax/span.php
Normal file
100
plugins/55/wrap/syntax/span.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
/**
|
||||
* Span Syntax Component of the Wrap Plugin
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Anika Henke <anika@selfthinker.org>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_span extends DokuWiki_Syntax_Plugin {
|
||||
protected $special_pattern = '<span\b[^>\r\n]*?/>';
|
||||
protected $entry_pattern = '<span\b.*?>(?=.*?</span>)';
|
||||
protected $exit_pattern = '</span>';
|
||||
|
||||
function getType(){ return 'formatting';}
|
||||
function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
|
||||
function getPType(){ return 'normal';}
|
||||
function getSort(){ return 195; }
|
||||
// override default accepts() method to allow nesting - ie, to get the plugin accepts its own entry syntax
|
||||
function accepts($mode) {
|
||||
if ($mode == substr(get_class($this), 7)) return true;
|
||||
return parent::accepts($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect pattern to lexer
|
||||
*/
|
||||
function connectTo($mode) {
|
||||
$this->Lexer->addSpecialPattern($this->special_pattern,$mode,'plugin_wrap_'.$this->getPluginComponent());
|
||||
$this->Lexer->addEntryPattern($this->entry_pattern,$mode,'plugin_wrap_'.$this->getPluginComponent());
|
||||
}
|
||||
|
||||
function postConnect() {
|
||||
$this->Lexer->addExitPattern($this->exit_pattern, 'plugin_wrap_'.$this->getPluginComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the match
|
||||
*/
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER:
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
$data = strtolower(trim(substr($match,strpos($match,' '),-1)," \t\n/"));
|
||||
return array($state, $data);
|
||||
|
||||
case DOKU_LEXER_UNMATCHED :
|
||||
$handler->addCall('cdata', array($match), $pos);
|
||||
return false;
|
||||
|
||||
case DOKU_LEXER_EXIT :
|
||||
return array($state, '');
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output
|
||||
*/
|
||||
function render($format, Doku_Renderer $renderer, $indata) {
|
||||
static $type_stack = array ();
|
||||
|
||||
if (empty($indata)) return false;
|
||||
list($state, $data) = $indata;
|
||||
|
||||
if($format == 'xhtml'){
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER:
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
$wrap = $this->loadHelper('wrap');
|
||||
$attr = $wrap->buildAttributes($data);
|
||||
|
||||
$renderer->doc .= '<span'.$attr.'>';
|
||||
if ($state == DOKU_LEXER_SPECIAL) $renderer->doc .= '</span>';
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_EXIT:
|
||||
$renderer->doc .= '</span>';
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if($format == 'odt'){
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER:
|
||||
$wrap = plugin_load('helper', 'wrap');
|
||||
array_push ($type_stack, $wrap->renderODTElementOpen($renderer, 'span', $data));
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_EXIT:
|
||||
$element = array_pop ($type_stack);
|
||||
$wrap = plugin_load('helper', 'wrap');
|
||||
$wrap->renderODTElementClose ($renderer, $element);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
18
plugins/55/wrap/syntax/spaninline.php
Normal file
18
plugins/55/wrap/syntax/spaninline.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Alternate span syntax component for the wrap plugin
|
||||
*
|
||||
* Defines <inline> ... </inline> syntax
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Anika Henke <anika@selfthinker.org>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_spaninline extends syntax_plugin_wrap_span {
|
||||
|
||||
protected $special_pattern = '<inline\b[^>\r\n]*?/>';
|
||||
protected $entry_pattern = '<inline\b.*?>(?=.*?</inline>)';
|
||||
protected $exit_pattern = '</inline>';
|
||||
|
||||
}
|
||||
|
19
plugins/55/wrap/syntax/spanwrap.php
Normal file
19
plugins/55/wrap/syntax/spanwrap.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Alternate span syntax component for the wrap plugin
|
||||
*
|
||||
* Defines <wrap> ... </wrap> syntax
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Anika Henke <anika@selfthinker.org>
|
||||
*/
|
||||
|
||||
class syntax_plugin_wrap_spanwrap extends syntax_plugin_wrap_span {
|
||||
|
||||
protected $special_pattern = '<wrap\b[^>\r\n]*?/>';
|
||||
protected $entry_pattern = '<wrap\b.*?>(?=.*?</wrap>)';
|
||||
protected $exit_pattern = '</wrap>';
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue