Correct formatting of the sample TOC on the Edition edit page
The formatting of the sample TOC on the Edition edit page is incorrect in that the notation for "Part 2" should not be indented. The attached screenshots show (1) the incorrectly formatted sample from the edit page, (2) how the incorrect formatting is rendered, and (3) how the correct formatting is rendered.
If this could be corrected, that would be wonderful. Thanks!
Thank you @Marla-1913 for submitting this issue!
Context
The sample TOC block lives in openlibrary/templates/books/edit/edition.html#L351-L354:
<pre class="smaller gray"> * Part 1 | THIS WORLD | 1
** Chapter 1 | Of the Nature of Flatland | 3
** Chapter 2 | Of the Climate and Houses in Flatland | 5
* Part 2 | OTHER WORLDS | 42</pre>
In the raw template source, the ** Chapter 1, ** Chapter 2, and * Part 2 lines each carry 8 leading spaces of indentation — that's just the Templetor source code's own indentation level, not intentional sample formatting. Because this sits inside an HTML <pre> tag (which preserves whitespace literally), and there's no white-space override in static/css for this .smaller.gray combination, those 8 spaces render as a real visual indent. Part 1, by contrast, only has a single leading space before its *. That's why Part 2 (and the chapter lines) appear indented relative to Part 1 in the rendered page, even though Part 2 is meant to be a sibling top-level entry at the same indent level.
The fix is to dedent lines 352–354 flush with the <pre> tag's opening so the rendered sample's whitespace matches the intended hierarchy (single space + * for top-level entries like Part 1/Part 2, extra space + ** for nested chapters).
No existing open issue or PR duplicates this — related TOC issues (e.g. #14147, #2142) are about parsing/data-model behavior, not this cosmetic sample-text formatting.
Triage checklist
Full triage checklist
- [x] Triage — correct labels applied or removed
- [x] Problem / opportunity — problem is clear, audience identified, actionable
- [x] Scope — issue is well-scoped; does not try to do too many things
- [x] Justification — reasoning and impact stated; sufficient for leads to prioritize
- [x] Success & testing criteria — defines what "done" looks like, verifiable by a contributor
- [x] Proposal & breakdown — concrete plan present; checklist actionable for a contributor
- [x] If bug: environment & repro steps — browser, version, local vs prod; steps to reproduce
- [x] Risks, concerns, open questions — identified and surfaced
- [x] Richy context — relevant code, commits, PRs reviewed; no duplicate found
- [x] References — screenshots, designs, docs, and links present where needed
⚠️ Contributors, this issue will be ready to work on once:
- [ ] Triage — maintainers will add
Priority: *andLead: @*
🔔 Stakeholders
@lokesh — frontend/template formatting issue on an edit-page macro; per the stakeholders table this area falls under frontend/design ownership. (Note: this repo checkout is shallow, so git blame/git log history on this file isn't available to confirm the most recent author directly.)
[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.
Hi @Marla-1913 I will work on this
Hi! I'd like to work on this issue.
I've identified the indentation problem in openlibrary/templates/books/edit/edition.html and prepared a small fix that aligns Part 2 with Part 1 while keeping the chapters nested.
Could you assign this issue to me once it's ready for contributions?
Thanks!
Thanks for the clear report and screenshots. The sample TOC is inside a <pre> block, so leading spaces in the template source are rendered literally. The Part 2 line and the chapter lines likely have extra source indentation that Part 1 does not, which causes the visual mismatch. A likely fix is to de-indent those lines inside the <pre> block so each sample line starts at the same column, then check the rendered edit page. This looks like a good candidate for a focused PR.
@Bhaskar-Guthula-137 could you create a PR for this?