Skip to content
Snippets Groups Projects
Unverified Commit 06917fce authored by Michael Große's avatar Michael Große
Browse files

fix: fix regex to return table secedit buttons

Since the hid is optional, it must also be optional in the regex. Also
this commit introduced named capture groups to make it more obvious
which part of the regex captures what.

Also there is now an explicit hid generated for tables, to enable
jumping to the correct section after finishing editing.

This was broken in 2571786c or #1966
respectively.

Known Issues:
* since both title and hid are optional, a hid may be misinterpreted as
a title if the title is not generated.
parent 5f28f727
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,7 @@ function html_denied() {
function html_secedit($text,$show=true){
global $INFO;
$regexp = '#<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )(?:"([^"]*)" )?\[(\d+-\d*)\] -->#';
$regexp = '#<!-- EDIT(?<secid>\d+) (?<target>[A-Z_]+) (?:"(?<name>[^"]*)" )?(?:"(?<hid>[^"]*)" )?\[(?<range>\d+-\d*)\] -->#';
if(!$INFO['writable'] || !$show || $INFO['rev']){
return preg_replace($regexp,'',$text);
......@@ -112,12 +112,16 @@ function html_secedit($text,$show=true){
* @triggers HTML_SECEDIT_BUTTON
*/
function html_secedit_button($matches){
$data = array('secid' => $matches[1],
'target' => strtolower($matches[2]),
'hid' => strtolower($matches[4]),
'range' => $matches[count($matches) - 1]);
if (count($matches) === 6) {
$data['name'] = $matches[3];
$data = array('secid' => $matches['secid'],
'target' => strtolower($matches['target']),
'range' => $matches['range']);
if (!empty($matches['hid'])) {
$data['hid'] = strtolower($matches['hid']);
}
if (!empty($matches['name'])) {
$data['name'] = $matches['name'];
}
return trigger_event('HTML_SECEDIT_BUTTON', $data,
......
......@@ -1339,7 +1339,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$class .= ' ' . $classes;
}
if($pos !== null) {
$class .= ' '.$this->startSectionEdit($pos, 'table');
$hid = $this->_headerToLink($class, true);
$class .= ' '.$this->startSectionEdit($pos, 'table', '', $hid);
}
$this->doc .= '<div class="'.$class.'"><table class="inline">'.
DOKU_LF;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment