Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let mdbook build select renderer and preprocessors #1978

Open
mgeisler opened this issue Jan 7, 2023 · 2 comments
Open

Let mdbook build select renderer and preprocessors #1978

mgeisler opened this issue Jan 7, 2023 · 2 comments

Comments

@mgeisler
Copy link
Contributor

mgeisler commented Jan 7, 2023

I'm adding support for translations to https://github.com/google/comprehensive-rust/ — via the code I posted in #1864. My plan is to do this via a renderer and a preprocessor:

  • a mdbook-gettext renderer collects the text from the entire book and outputs a messages.pot file which is ready to be translated
  • a translate preprocessor uses a xx.po file (with translations) to translate the text on-the-fly into an output language.

Hooking into mdbook like this seems nice: I don't need to know about where the Markdown files are on disk and I can reuse things such as BookItem.

However, I don't need the renderer and the preprocessor most of the time: I only need them when publishing a new version. It would therefore be nice if mdbook build would have new command line options which lets me enable/disable the renderer and preprocessor.

Does that sound like a reasonable idea? I think mdbook serve should have the same options.

My workaround right now is to modify the book.toml file to enable the renderer and preprocessor when needed.

@mgeisler
Copy link
Contributor Author

I found a better work-around: use the MDBOOK_ environment variable to override the renderer and preprocessor as needed.

With that, I think this issue can be closed.

@mgeisler
Copy link
Contributor Author

We had a discussion in google/comprehensive-rust#1998 about a similar topic: how can we include configuration for a renderer (mdbook-pandoc in this case) without requiring that everybody installs the dependencies for the renderer?

One solution would be to let mdbook build and serve take a list of renderer to use. That would be a subset of the renderers configured in book.toml.

Another solution just occurred to me: we could extract the configuration that isn't used all the time to a separate file. When we want to use it, we do something like

MDBOOK_OUTPUT=$(cat pandoc.json) mdbook build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant