1
0
Fork 0

Adding edittable version 2023-01-14 (66785d9).

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2024-12-01 20:32:06 +01:00
parent 51b386fcf7
commit 778f9ac0bf
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
101 changed files with 56770 additions and 0 deletions

View file

@ -0,0 +1,54 @@
<?php
require_once dirname(__FILE__).'/../renderer/inverse.php';
/**
* @group plugin_edittable
* @group plugins
*/
class renderer_plugin_edittable_inverse_test extends DokuWikiTest {
function test_externallink() {
$input = '[[file:///x:\folder\file.zip]]';
$output = $this->render($input);
$this->assertEquals($input, $output);
}
function test_fullsyntax() {
$input = io_readFile(dirname(__FILE__).'/'.basename(__FILE__, '.php').'.txt');
$this->assertTrue(strlen($input) > 1000); // make sure we got what we want
$output = $this->render($input);
$input = $this->noWS($input);
$output = $this->noWS($output);
$this->assertEquals($input, $output);
}
/**
* reduce spaces and newlines to single occurances
*
* @param $text
* @return mixed
*/
protected function noWS($text) {
$text = preg_replace('/\n+/s', "\n", $text);
$text = preg_replace('/ +/', ' ', $text);
return $text;
}
/**
* render the given text with the inverse renderer
*
* @param $text
* @return string
*/
protected function render($text) {
$instructions = p_get_instructions($text);
$Renderer = new renderer_plugin_edittable_inverse();
foreach($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
return $Renderer->doc;
}
}