feat: Update chapter title formatting and enhance settings layout

This commit is contained in:
JB
2025-10-14 07:37:28 -07:00
parent 6248dfdc0c
commit 6ae8b827d2
5 changed files with 38 additions and 6 deletions
+4 -1
View File
@@ -99,7 +99,10 @@ def _format_spoken_chapter_title(title: str, index: int, apply_prefix: bool) ->
if match:
number = match.group("number") or ""
suffix = match.group("suffix") or ""
return f"Chapter {number}{suffix}"
cleaned_suffix = suffix.lstrip(" .,:;-_\t\u2013\u2014\u00b7\u2022")
if cleaned_suffix:
return f"Chapter {number}. {cleaned_suffix}"
return f"Chapter {number}"
return base
+26
View File
@@ -1517,6 +1517,32 @@ button.step-indicator__item:focus-visible {
grid-column: 1 / -1;
}
.settings__section .field {
align-items: flex-start;
}
.settings__section .field input,
.settings__section .field select,
.settings__section .field textarea {
max-width: 100%;
}
.settings__section .field input[type="text"],
.settings__section .field input[type="file"],
.settings__section .field select {
max-width: 100%;
}
.settings__section .field--wide {
grid-column: 1 / -1;
}
.settings__section .field--wide input,
.settings__section .field--wide select,
.settings__section .field--wide textarea {
max-width: 100%;
}
.field--choices {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+1 -2
View File
@@ -1111,8 +1111,7 @@
}
}
if (titleEl) {
const chapter = chapters[currentChapterIndex];
titleEl.textContent = chapter?.title ? `${chapter.title} · ${baseTitle}` : baseTitle;
titleEl.textContent = baseTitle;
}
if (chapterPanelToggleBtn) {
chapterPanelToggleBtn.disabled = !hasChapters;
+2 -2
View File
@@ -36,7 +36,7 @@
<input type="number" min="1" max="25" id="speaker_analysis_threshold" name="speaker_analysis_threshold" value="{{ settings.speaker_analysis_threshold }}">
<p class="hint">Speakers detected fewer times fall back to the narrator voice.</p>
</div>
<div class="field">
<div class="field field--wide">
<label for="speaker_pronunciation_sentence">Speaker Pronunciation Preview</label>
<input type="text" id="speaker_pronunciation_sentence" name="speaker_pronunciation_sentence" value="{{ settings.speaker_pronunciation_sentence }}" placeholder="This is {{ '{{name}}' }} speaking.">
<p class="hint">Include <code>{{ '{{name}}' }}</code> where the speaker name should be inserted.</p>
@@ -48,7 +48,7 @@
</label>
<p class="hint">Disable if you prefer to skip entity extraction in the job wizard.</p>
</div>
<div class="field">
<div class="field field--wide">
<label for="speaker_random_languages">Randomizer Languages</label>
{% set selected_languages = settings.speaker_random_languages or [] %}
<select id="speaker_random_languages" name="speaker_random_languages" multiple size="6">
+5 -1
View File
@@ -6,7 +6,7 @@ from abogen.web.conversion_runner import (
def test_format_spoken_chapter_title_adds_prefix() -> None:
assert _format_spoken_chapter_title("1: A Tale", 1, True) == "Chapter 1: A Tale"
assert _format_spoken_chapter_title("1: A Tale", 1, True) == "Chapter 1. A Tale"
def test_format_spoken_chapter_title_respects_existing_prefix() -> None:
@@ -17,6 +17,10 @@ def test_format_spoken_chapter_title_handles_empty_title() -> None:
assert _format_spoken_chapter_title("", 4, True) == "Chapter 4"
def test_format_spoken_chapter_title_trims_delimiters() -> None:
assert _format_spoken_chapter_title("7 - Into the Wild", 7, True) == "Chapter 7. Into the Wild"
def test_headings_equivalent_ignores_case_and_prefix() -> None:
assert _headings_equivalent("1: The House", "Chapter 1: The House")