Sommerregen / grav-plugin-toc

This plugin automagically generates a (minified) Table of Contents based on special markers in the document and adds it into the resulting HTML document.
Other
14 stars 11 forks source link

TOC plugin doesn't work on GravCMS 1.7 #27

Open nex84 opened 3 years ago

nex84 commented 3 years ago

TOC plugin doesn't work on GravCMS 1.7 with PHP 8

It raises the following error :

Whoops \ Exception \ ErrorException (E_COMPILE_ERROR) Array and string offset access syntax with curly braces is no longer supported

It seems located in the file plugins/toc/classes/Toc.php line 68 :

            // Ignore headings in code, pre or blockquote environments
           if (!$text || $tag{0} !== 'h') {
               continue;
           }
nex84 commented 3 years ago

As per https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/59158847#59158847 I guess the correct syntax should now be $tag[0] instead of $tag{0}