Skip to content

How does MDBOOK_XXX env deal with configuration strings with an undersore (_)? #2739

@hwhsu1231

Description

@hwhsu1231

Question

Recently, I tried to build Zed docs without using its custom preprocessor, [preprocessor.zed_docs_preprocessor].

Originally, I thought I could use MDBOOK_XXX env to disable it by assigning it with an empty object, {}, like this:

MDBOOK_PREPROCCESSOR__ZED_DOCS_PREPROCESSOR={} mdbook build docs

However, it failed because mdbook will recognize:

MDBOOK_PREPROCCESSOR__ZED_DOCS_PREPROCESSOR -> [preprocessor.zed-docs-preprocessor]

Based on the Environment Variables section:

Variables starting with MDBOOK_ are used for configuration. The key is created by removing the MDBOOK_ prefix and turning the resulting string into kebab-case. Double underscores (__) separate nested keys, while a single underscore (_) is replaced with a dash (-).

For example:

  • MDBOOK_foo -> foo
  • MDBOOK_FOO -> foo
  • MDBOOK_FOO__BAR -> foo.bar
  • MDBOOK_FOO_BAR -> foo-bar
  • MDBOOK_FOO_bar__baz -> foo-bar.baz

It seems that mdbook's MDBOOK_XXX env can deal with configuration strings with a dash (-) and a dot (.), but it cannot deal with an underscore (_).

My questions are:

  1. If so, does it mean that it's not recommended to use _ in configuration strings?
  2. If not, then how does MDBOOK_XXX env deal with configuration strings with _?

Version

mdbook v0.4.40

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-questionCategory: A question on how to do something

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions