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

Preprocessors cannot modify SUMMARY.md #1979

Closed
mgeisler opened this issue Jan 7, 2023 · 3 comments
Closed

Preprocessors cannot modify SUMMARY.md #1979

mgeisler opened this issue Jan 7, 2023 · 3 comments

Comments

@mgeisler
Copy link
Contributor

mgeisler commented Jan 7, 2023

Hi there,

As far as I can tell, a preprocessor is not executed on the data in SUMMARY.md. If that is true, can be change this somehow?

My usecase for this is to support translations via a mdbook preprocessor. However, if the preprocessor doesn't have access to the outline, it cannot translate it 😄

A simple work-around for me is to translate all the Markdown files (including SUMMARY.md) manually via an external script. However, it would be nice to have the whole thing integrated with mdbook.

@ehuss
Copy link
Contributor

ehuss commented Jan 7, 2023

Preprocessors should be able to modify the summary from the sections array. IIRC, all the information of the summary (such as the chapter names) are stored within. You won't be able to modify the file as a whole.

@mgeisler
Copy link
Contributor Author

mgeisler commented Jan 7, 2023

Oh, cool, I'll take a look at that. I was looking at the BookItem enum and that only seems to give me the headers between the chapters — not the actual chapters from the sidebar.

@mgeisler
Copy link
Contributor Author

mgeisler commented Jan 8, 2023

Ah, I got it now! I need to translate the name field in Chapter. The updated name is used in the sidebar. I do have access to this from a BookItem::Chapter.

Thanks!

@mgeisler mgeisler closed this as completed Jan 8, 2023
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

2 participants