fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
318 stars 50 forks source link

Allow pages to opt-in, instead of opt-out. #159

Closed attie closed 1 year ago

attie commented 1 year ago

I have many, many pages, but would like to use Jinja2 rendering on only one new page. This patch will make the ignore_macros configuration available at the global level, effectively permitting individual pages to "opt-in" using ignore_macros: true, instead of only "opt-out" using ignore_macros: false.

hexus commented 1 year ago

permitting individual pages to "opt-in" using ignore_macros: true, instead of only "opt-out" using ignore_macros: false.

You mean this the other way round, right? ignore_macros: false to opt-in, when it's set to true globally. Double-negatives can be confusing. 😁 Oh, I see what you mean. It could be set to ignore_macros: true globally to allow pages to opt-in. I misunderstood the context!

If it were my design, I'd have this config renamed to something like enabled, or enable_macros, set to true globally by default. Then pages could opt-out with enable_macros: false, or inversely you could disable globally in MkDocs config and use enable_macros: true on a page to opt in.

attie commented 1 year ago

Double-negatives can be confusing

Hah...

It could be set to ignore_macros: true globally to allow pages to opt-in.

Yeah, exactly - disable macros globally, and then re-enable them for the pages that need to use macros.

If it were my design

If I was implementing it fom scratch, I would probably have picked upright logic too (rather than inverted)... but I didn't want to disrupt / confuse the ignore_macros that is already present at the page level... This way, we keep a setting (ignore_macros), which can now be set globally, and overridden on a per-page basis.

fralau commented 1 year ago

This is attached to issue #162 (a slightly different solution was adopted).

hexus commented 1 year ago

I really like that solution! 🙌

fralau commented 1 year ago

Thanks a lot for your helpful contribution.