tommilligan / mdbook-admonish

A preprocessor for mdbook to add Material Design admonishments.
MIT License
175 stars 20 forks source link

Allow to set the collapsible property for each directive #174

Closed yannickseurin closed 5 months ago

yannickseurin commented 6 months ago

Allows to set the collapsible property independently for each directive (overwriting the global default) as suggested in issue #169 .

When resolving a block, the value of collapsible is set to

Note that the updated documentation specifies that the table for builtin directives must be declared as

[preprocessor.admonish.default.builtins_collapsible]

which assumes that PR 173 is merged (otherwise it should be builtins-collapsible).

tommilligan commented 5 months ago

This ended up turning into a big rewrite, but I'm happy with the outcome. The upshot is that we can now configure in a uniform style like:

[preprocessor.admonish.directive.builtin.warning]
collapsible = true

[preprocessor.admonish.directive.custom.expensive]
icon = "./money-bag.svg"
color = "#24ab38"
collapsible = true
aliases = ["money", "cash", "budget"]

The old style configuration for custom is supported backwards compatibly. This leaves room for further PRs to add overrides for builtin directives aliases, icons etc. if people want that in future.

yannickseurin commented 5 months ago

Very neat, thanks for this! And sorry for having prompted such a big rewrite :)

tommilligan commented 5 months ago

Very neat, thanks for this! And sorry for having prompted such a big rewrite :)

Not a problem! It was in my mind for a while and it worked to get it out here. Also prompted by problems with the existing format and the old version of toml that mdbook uses internally - it has a bug in it such that the table-of-tables approach I was using literally broke when used :disappointed: