lisps / const

Dokuwiki Plugin
http://dokuwiki.org/plugin:const
GNU General Public License v2.0
2 stars 4 forks source link

Plugin doesn't work at all #1

Closed ajfre closed 5 years ago

ajfre commented 10 years ago

1st reason: Line 220: if($ID != $this->page) return; is always true, since $this->page is always ''

2nd reason: empty lines are thrown away and cause misaligned sections: Line 83: $data = preg_split('/[\r\n]+/', $data, -1, PREG_SPLIT_NO_EMPTY); is the origin of this misbehaviour.

Why did you publish this really useless plugin?

lisps commented 10 years ago

hi ajfre, can you give me some more infos?

ajfre commented 10 years ago

I didn't test the math functions. I analyzed the offset alignment, copied it into an own plugin and found, that it doesn't work, because of line 220 and the fact, that $this->page is never set to a value other than ''

After correcting this, I got invalid section alignment, if multible blank lines are in the raw text. Reason: line 83, which eats them. Changeing the pattern to /\r?\n/ will make it work.

What is the reason for that trivial syntax component? As far as I see, it does simply nothing.

Regarding the section alignment: this stuff is quite generic and should be implemented as interface to a kernel function.

lisps commented 10 years ago

as described in https://www.dokuwiki.org/plugin:const you can define constants and math calculations anywhere on a page (inside tags) and use them afterwards on the same page. The syntax component just hides the defines inside the tags, because they should not be displayed to the user.

The code on line 220 in action.php is to remove the blank lines as it is part of parsing the defines. It has no effect to the wiki page.

Just for my info: are you using the const plugin and having problems to get it work, or have you problems getting parts of the code working in an other plugin?

ajfre commented 10 years ago

No, I don't use const in my wiki. I only used as a source for the trick to realign the code and found, that it doesn't work correctly. (A bunch of action plugins has very similar issues and for plugin users it is very difficult to find the culprit for these effects, that frequently garble page text.)

To see the misbehaviour, try this page text (including all blank lines!):

print=Calculation value1=10 value2=30 value3=%RANDOM% formular=(value1 \* value2) + (value3 / 2) result:formular

%%print%% => %%formular%% = %%result%%

====== Section 1 ======

12345678901234567890

====== Section 2 ======

12345678901234567890 12345678901234567890

====== Section 3 ======

12345678901234567890


Save it and then click "Edit" for the sections. DW's opinion about these sections in the section editor is not what the source text suggests.

ajfre commented 10 years ago

PS.: The syntax component of const is not really needed. The -section can be removed in PARSER_WIKITEXT_PREPROCESS.

ajfre commented 10 years ago

PPS: Sorry, the bugtracker has thrown away anything, that looks like a html tag.

The const code in my example code is from https://www.dokuwiki.org/plugin:const

'The -section' in my PS was intended to be 'const-section', const in angle brackets.

lisps commented 10 years ago

if i hide the const section with the syntax compontent, i don't have to deal with the section-correction

The code example works for me, I am using weatherwax - and only have tested it against this version. Users have selected it as compatible with binky and adora.

ajfre commented 10 years ago

The code example works for me, I am using weatherwax - and only have tested it against this version. Users have selected it as compatible with binky and adora.

I use Binky. Did you open sections for edit? Not the whole page.

if i hide the const section with the syntax compontent, i don't have to deal with the section-correction

Only, if the variable substitutions do not cause changes of the text lengt.

Offsets in code are computed from rendered text. If preprocessing modified the raw text length, section headings move to new offsets. Section-correction is necessary to make section headers etc. in the code point to the section in the raw text on disk. That is necessary for the section editor to correctly get the section.

Here some screen shots + wiki source https://dl.dropboxusercontent.com/u/55092578/PluginList.png https://dl.dropboxusercontent.com/u/55092578/RenderedText.png https://dl.dropboxusercontent.com/u/55092578/source.png https://dl.dropboxusercontent.com/u/55092578/SectionEdit.png https://dl.dropboxusercontent.com/u/55092578/src.txt

Be aware, that the random function in your code causes differences in offsets.

lisps commented 10 years ago

i have pushed some updates to the master branch. Can you please test it? if it doesn't work, you can try to delete your cache directory (data/cache/[0-f]) and test again.

thanks