gturri / nspages

Plugin for dokuwiki - Display tables of content
http://www.dokuwiki.org/plugin:nspages
GNU General Public License v2.0
25 stars 24 forks source link

Include all whitespace when removing matched option #154

Closed dregad closed 1 year ago

dregad commented 1 year ago

Previously, only space was considered. This caused error when the nspages tag spanned multiple lines and there was no trailing space before the newline.

Fixes #153

gturri commented 1 year ago

Thanks for that PR! :)

Unfortunately, I have the feeling that it reintroduces the bug that was fixed by https://github.com/gturri/nspages/commit/1042ed49fa69b9d80dfae820a41a624f7c0751eb

for instance <nspages -exclude:page1 -exclude:page10> fails with This namespace does exist :0 with the commit of this PR :-/

dregad commented 1 year ago

I'll have a look

gturri commented 1 year ago

FTR: I think I found a way, with this code

    static private function _removeFromMatch($matched, $match){
        $matched = trim($matched); // to handle the case of the option "-r" which already matches an extra whitespace
        $match = substr(str_replace($matched.' ', ' ', $match.' '), 0, -1);                                  
        return substr(str_replace($matched."\n", ' ', $match.' '), 0, -1);                                   
    }

I need to test it a bit more though

gturri commented 1 year ago

It seems it works with this approach. I'm not too sure it would really work on Windows, I should try to test it there, but at least it improves the situation already so I'll merge that

gturri commented 1 year ago

Superseded by b18078ae27719cc1c9204cbca63975b6100496ab