Filters frontmatter includes for single chapters

Simplifies frontmatter inclusion logic to retain only
'index.qmd' when building single chapter books,
removing unnecessary checks for other frontmatter files.
This commit is contained in:
Vijay Janapa Reddi
2025-08-16 13:39:53 -04:00
parent 3734b449f1
commit 3b395f6206

30
binder
View File

@@ -381,8 +381,8 @@ class BookBinder:
# Keep the target chapter
new_lines.append(line)
target_found = True
elif any(essential in line for essential in ['index.qmd', 'foreword.qmd', 'about/', 'acknowledgements/']):
# Keep essential frontmatter
elif 'index.qmd' in line:
# Keep only index.qmd from frontmatter
new_lines.append(line)
else:
# Comment out other chapters
@@ -472,8 +472,8 @@ class BookBinder:
# Keep target chapters
new_lines.append(line)
targets_found += 1
elif any(essential in line for essential in ['index.qmd', 'foreword.qmd', 'about/', 'acknowledgements/']):
# Keep essential frontmatter
elif 'index.qmd' in line:
# Keep only index.qmd from frontmatter
new_lines.append(line)
else:
# Comment out other chapters
@@ -763,17 +763,17 @@ class BookBinder:
if success:
console.print(f"[green] ✅ Fast build complete: {self.get_output_dir(format_type)}/[/green]")
# Automatically open the output file if HTML and requested
if format_type == "html" and output and open_browser:
# Check user preference for auto-open
preferences = self.get_user_preferences()
auto_open = preferences.get('auto_open', True)
if auto_open:
self.open_output_file(output)
else:
console.print(f"[blue]📄 Output ready: {output}[/blue]")
console.print("[dim]💡 Set auto-open preference with './binder setup'[/dim]")
# Automatically open the output file if HTML and requested
if format_type == "html" and output and open_browser:
# Check user preference for auto-open
preferences = self.get_user_preferences()
auto_open = preferences.get('auto_open', True)
if auto_open:
self.open_output_file(output)
else:
console.print(f"[blue]📄 Output ready: {output}[/blue]")
console.print("[dim]💡 Set auto-open preference with './binder setup'[/dim]")
else:
console.print("[red] ❌ Build failed[/red]")