Scoped, switchable named text styles (+ align / underline) - #7
Merged
Conversation
Add named text styles and a frame-scoped `_textstyle` block to switch between them within report source, without introducing global parse-time state. - `_style.styles` declares named families as sparse overrides of the default body/headings family (inherit-from-body). - `_textstyle: <name>` switches the active family for the rest of its recursion frame and is inherited by descendant frames, reverting when the frame returns. Switching swaps the whole family (body, bullets, and derived headings). - State is threaded as a `current_style` parameter through build_story and the content converters -- no global mutable cursor. - Config merge now carries user-defined extension keys (named `styles`) that the defaults have no schema for. Includes a design doc (design/scoped-text-styles.md), an example (Examples/Text Styles), and tests covering inheritance, whole-family heading rescale, scoping/revert, and error cases. Scope limits (documented): only paragraphs, headings, and lists honour the active style; other blocks keep default styling. Names only, no index. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add two per-style formatting attributes that compose with named text styles: - `align` (left/center/right/justify) on body, headings, and named styles, mapped to ReportLab's native ParagraphStyle.alignment via convert_alignment(). - `underline` (bool) applied at render time by wrapping text in <u>...</u>, since ParagraphStyle has no honored underline attribute. Applies to paragraphs and headings; bullets are not wrapped. Both live on a shared FormatMixin so they are inherited by named styles like any other field. Updates the example and design doc; adds tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add report_example_4.yml showcasing named text styles, _textstyle switching (both the list-item and mapping-key forms), per-style alignment, and heading / body underline, then render it through load_report in test_load_yaml alongside the other example reports. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
connorferster
force-pushed
the
features/scoped-text-styles
branch
from
August 13, 2026 22:15
3b1b690 to
b1b8064
Compare
connorferster
changed the base branch from
main
to
features/explicit-list-syntax
August 13, 2026 22:15
connorferster
changed the base branch from
features/explicit-list-syntax
to
main
August 13, 2026 22:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds named text styles and a frame-scoped
_textstyleblock to switch between them within report source, plus per-stylealignandunderline— without introducing global parse-time state.Builds on #6 (explicit list syntax), which is now merged into
main; this branch is rebased on top, so the diff is text-style changes only.Changes
_style.stylesdeclares named families as sparse overrides of the default body/headings family (inherit-from-body)._textstyle: <name>switches the active family for the rest of its recursion frame, inherited by descendants, reverting when the frame returns. Switching swaps the whole family (body, bullets, derived headings).current_styleparameter throughbuild_storyand the content converters — no global mutable cursor.styles).align(left/center/right/justify) → ReportLabParagraphStyle.alignment;underline(bool) via<u>…</u>.Composition with the list syntax (#6)
_ul/_olare intercepted inbuild_storywith the activecurrent_stylethreaded in, so bullets/numbers honour the surrounding_textstylescope (verified: a_ulinside a fine-print scope renders at the fine-print size).report_example_4.ymluses_ul/_ol.Testing
45 tests pass on the composed code, incl.
tests/test_scoped_text_styles.pyand thereport_example_4.ymlintegration render.Design doc:
design/scoped-text-styles.md.🤖 Generated with Claude Code