Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have a problem using this plugin since my site is primarily written in an alphabet for which "slugify" has no ruleset. This results in all slugs being output as an empty string. One solution would be to try to get a ruleset added to slugify for my language. Strictly speaking, however, this isn't necessary, as slugs don't have to be in ASCII. It would be sufficient to modify the regex expression that determines which characters are thrown away when creating the slug. This is allowed through the slugify option "regexp". This option and others are also exposed to the user in PHP TOC Generator, on which this plugin is based (you can even inject your own sluggifier). However, as far as I can tell, the user of this Grav plugin has no ability to modify the slugify parameters without making changes to the plugin itself.
In this commit I attempted to allow for this possibilty in the least intrunsive way possible, by taking advantage of the options parameter passed to the
fix
method ofMarkupFixer
. The user can make changes to any of the slugify parameters by modifying page-toc.yaml. If this is not done, thefix
method should receive the exact same array as before this commit. I also did this so as not to have to hardcode any defaults of the slugify options.I didn't make any changes to blueprints.yaml or the deafult page-toc.yaml, in case you don't want to make the possibility of modifying the slugify options to be too obvious to the user. (As I said I was going for minimal intrusiveness.)
Since the possibility of changing the regexp option allows (as in my case) for non-ASCII slugs, I also replaced a couple string functions with their mb_ versions.
I've tested this, changing around different slugify options on my site, and as far as I can tell it works correctly.