Not logged in. · Lost password · Register
Forum: General Help and Support Features and Functionality RSS
Issues with section editing; possible because macros plugin
Avatar
cristian607 #1
Member since Dec 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Issues with section editing; possible because macros plugin
Hello,

I have 2 wikis powered by DokuWiki, and I have noticed, that sometimes section editing works, and other times it doesn't work (i.e. the "Edit" buttons don't appear. I have DokuWiki Adora Belle + the standar "dokuwiki" template. But I have seen this problem on my other wiki as well: Angua + arctic-mbo template.

The issue seems to appear in pages where I use the macros plugin. E.g.
$myMacro

It's interesting that even if I escape the $ in the above line, and surround it with <nowiki> tags, the macro isn't executed and the text is displayed as-is, but the section editing still doesn't work; e.g.:

<nowiki>
`$myMacro
</nowiki>

On the plugin:macro page ( https://www.dokuwiki.org/plugin:macros#bug_report ), someone else tried to look, ending up with the following conclusion:

if a macro is processed, that changes the length of a section text. It may even generate new sections! I could not find how to make dokuwiki adjust the sections (and positions of edit buttons) properly

Have you got any ideea what is happening? Or at least some pointers on why that may happen, so I can start digging in the macros plugin? I mean why the processing of this plugin would mess the dokuwiki logic that counts sections? The fact that the rendering of the macro changes the length of the text (cf. the quote above) shouldn't be an issue, because all syntax plugins are expected to do so: i.e. replace the wiki syntax with a text having an unknown length.

Thank you in advance.

Best regards,
Cristian.
Avatar
cristian607 #2
Member since Dec 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
I come with an update. Actually, the edit buttons disappear because they are explicitly hidden, on PARSER_WIKITEXT_PREPROCESS:

    global $conf; $conf['maxseclevel'] = 0;

But if I disable the line, the edit buttons appear, but they don't work correctly. E.g. the following macro replaces the $text expression, with a predefined text, that has 28 characters:

{{$test=
This text has 28 characters.
$}}

I have the following wiki page:

====== Pag 1 ======

===== Headline1 =====

$test

==== Headline2 ====

That renders like this:

Pag 1
Headline1

This text has 28 characters.
Headline2

But when I hit the edit button for Headline1, this is what I get:

===== Headline1 =====

$test

==== Headline2 ====


<h

It seems that dokuwiki calculates the indexes for sections AFTER the macros plugin has done the insertion. Is that caused because the replacing gets done in the PARSER_WIKITEXT_PREPROCESS event?

         $controller->register_hook('PARSER_WIKITEXT_PREPROCESS',    'BEFORE', $this, '_macros_pre',            NULL);

Should the replace of the text be done on another event? I assume that the replace was done early in the flow, so that the macro text may contain wiki syntax, that's parsed afterwards.

Best regards,
Cristian
Avatar
Michitux #3
Member since Apr 2008 · 377 posts · Location: Karlsruhe, Germany
Group memberships: Members, Wiki Managers
Show profile · Link to this post
This is definitely because of the macros plugin, the problem is that in order to support replacements that contain wiki syntax, i.e. replacements on text level, the replacement needs to be done before the content is parsed. However the position of the sections is determined while the text is parsed, so they are wrong. I think there are two possible solutions:

- the replacement is done later and won't be that flexible, i.e. replacements would only be possible in the text content and not across different syntax elements and could not introduce new syntax. The advantage would be that replacements could be selective, i.e. they could exclude code blocks etc.
- the macros plugin stores the positions of the replacements and corrects the positions of the sections using this information. This is not trivial, especially when macros introduce new sections etc. I think the easiest way is to go through the instructions after they are generated (in the PARSER_HANDLER_DONE event) and correct the position information that is stored in the header instructions (and table instructions for the edittable plugin).
Did you like my help or work for DokuWiki (plugins)? Consider giving something back.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2018-04-21, 06:08:10 (UTC +02:00)