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

Can chapters in the table of contents be collapsed? #86

Open
dead-summer opened this issue Oct 7, 2024 · 5 comments
Open

Can chapters in the table of contents be collapsed? #86

dead-summer opened this issue Oct 7, 2024 · 5 comments

Comments

@dead-summer
Copy link

Shiroa provides Part Title to separate different chapters, which makes the book look clear. But if there are too many sub-chapters, the directory will be very long. Can we fold the chapters to make the entire directory clearer?

As the document has mentioned how to fold, please give me some advice :)

@Myriad-Dreamin
Copy link
Owner

If I understand it correctly, we cannot yet, but it sounds like a nice feature. The current theme is borrowed from mdbook, used by rust lang, and they cannot as well.

@dead-summer
Copy link
Author

Thanks for your reply. Based on your suggestion, I read some code from mdbook. And I found it has the ToC collapse feature and similar functionality is included in shiroa.

The difference is that lines 43 and 44 of html.rs in shiroa are as follows:

data.insert("fold_enable".to_owned(), json!(false));
data.insert("fold_level".to_owned(), json!(0u64));

While in mdbook:

data.insert("fold_enable".to_owned(), json!((html_config.fold.enable)));
data.insert("fold_level".to_owned(), json!((html_config.fold.level)));

Being new to Rust, I simply changed data.insert("fold_enable".to_owned(), json!(false)); in html.rs to data.insert("fold_enable".to_owned(), json!(true));, but that didn't work.

mdbook may also contain other details, and how can we further implement this feature?

@Myriad-Dreamin
Copy link
Owner

Wonderful, I forgot the feature was removed by myself. I'll do that for you in this weekend.

@ice1000
Copy link
Contributor

ice1000 commented Oct 18, 2024

Wonderful, I forgot the feature was removed by myself. I'll do that for you in this weekend.

Can you share what other things need to be done? Maybe someone else can do it

@Myriad-Dreamin
Copy link
Owner

@ice1000 If I judge it correctly, we just need to add fold-xxx configurations to the book meta or build meta of book.typ. The sample configuration is repository, which is specified in book meta and used in html.rs:

if let Some(repo) = data.get("repository") {
data.insert("git_repository_url".to_owned(), repo.clone());
data.insert("git_repository_icon".to_owned(), json!("fa-github"));
}

/// - repository (str): The github repository for the book.

The not clear thing is that the fold-xxx configurations sound like "theme config" rather than some "book meta".

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

3 participants