Skip to content

Bio links, paragraph breaks, and description parsing (#137, #138) - #143

Merged
zhollis21 merged 6 commits into
mainfrom
feature/137-138-bio-link-and-paragraph-rendering
Aug 28, 2026
Merged

zhollis21 merged 6 commits into
mainfrom
feature/137-138-bio-link-and-paragraph-rendering

Conversation

@zhollis21

@zhollis21 zhollis21 commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

Closes #137. Closes #138.

Character and staff bios lost both their words and their shape: every markdown
link rendered as an invisible gap, and every paragraph break was discarded.
Sampling the 50 most-favourited characters and staff settled the scale — 42 of 50
bios contain a link, 47 of 50 contain a paragraph break.

Links (#137)

Html.FromHtml turns each anchor into a URLSpan, which ignores the label's
TextColor and paints itself with the TextView's textColorLink. That resolves
through Theme.MaterialComponents.DayNight to colorAccent, which colors.xml
sets to transparent so the rainbow theming can show through — hence link text
painted transparent while still occupying its own width.

BioLinkSpans swaps each URLSpan for a span that paints itself, which
sidesteps textColorLink rather than overriding it: colorAccent stays
transparent and the theming is untouched. Colour comes from the rainbow palette
keyed on the link text, through a ResourceKeyFor extracted from
RainbowAccentConverter so a name always paints the same colour wherever it
appears. Taps route in-app via AniListLinkTarget, a pure Core function — AniList
character, anime, staff and studio links reach the matching page (162 of 235
sampled links), everything else goes to IExternalBrowser.

Two non-obvious things about the Android hook, both of which cost a device
cycle to find and neither of which is visible from the code:

  • It must be registered under a custom mapper key. Label.RemapForControls
    swaps LabelHandler.Mapper for a ControlsLabelMapper that defines Text and
    TextType itself, off Label's static init during the first page render — so a
    registration on those keys is shadowed and silently never runs, before or after
    builder.Build(). No error, links simply stay invisible.
  • Because a custom key only runs when the handler is built, a TextWatcher
    re-applies the spans on text change. Without it the links go invisible again
    the first time spoilers are toggled.

Touch handling is a BaseMovementMethod, not LinkMovementMethod — the latter
extends ScrollingMovementMethod and would steal vertical drags from the page's
ScrollView.

Breaks (#138)

AniListMarkdownProcessor emits <br> per newline and a doubled break for a
blank line. Every newline becomes a break, lone ones included: AniList does
not hard-wrap prose — across the 50 sampled bios not one lone newline fell
mid-sentence — so a lone newline is always deliberate structure, most visibly the
bullet lists in staff bios. This reverses the direction #138 originally leaned
towards, and the reasoning is recorded on the issue. Patterns match \r?\n
because DescriptionParser builds prose with AppendLine.

Truncation moved with it. IsTruncated was being handed the raw markdown, which
counts link URLs as visible text and contains none of the break tags it looks
for, so that branch was dead here; it now receives the rendered BioProse.
CharsPerLine drops 45 → 40 for Body2's real 15sp, so the estimate now errs
towards a redundant "Read more" rather than silently tail-truncating text the
reader cannot reach.

Beyond the two issues

Flagged during review and on device, each agreed before it went in:

MediaDetailsPageModel Carried its own copy of the whole heuristic at 45, behind a label identical to the bio ones — same silent-chop bug. Now calls the shared helper; a test pins it against the duplicate returning. Changes "Read more" behaviour on a page neither issue covers.
Multi-line spoiler blocks A ~!…!~ block spanning several stat rows only parsed single-line, so stat parsing ended early and later rows fell into the prose card. Character 40 lost three rows.
__Height__: spelling Colon outside the underscores was unrecognised, and a miss on the first line latches the parser into prose — so those bios lost their entire stat card. 5 of 200 sampled: Naruto, Sasuke, Kurapika, Joseph Joestar, Gabi Braun.
Stat row values Never ran through the markdown processor, so a link in a value showed a literal [name](url) beside prose that rendered correctly.
_italic_ Single-underscore italics were unhandled, leaving underscores on screen in 9 of 200 sampled bios. Pattern is fenced by non-word lookarounds so snake_case is untouched.

Manga links are deliberately not routed: the details page queries
Media(type: ANIME), so a manga id 404s there. They show the same "not supported
yet" message NavigateToMedia already gives, and the removal steps are recorded
on #12.

Verification

The rendering half cannot be unit-tested, so it was checked on device against the
live API, signed out — Luffy, Eiichirou Oda and Naruto Uzumaki:

  • Links visible and coloured; BIOLINK replaced 6 / 4 / 2 link span(s) matching
    the counts predicted from the API
  • Tapping routes in-app: NAVTRACE BioLink → character-details with id=12281
  • Swiping from inside the bio still scrolls the page
  • Paragraph breaks and the __Trivia:__ bullet list render correctly
  • Spoiler toggle re-applies spans — replaced 2 then replaced 5 once revealed
  • Naruto's stat card restored; (a _Jinchuuriki_) renders italic

The string half adds 58 tests (1192 → 1250). Bug fixes were written red first;
the four spoiler-interaction tests passed on the first run, so they pin existing
correct behaviour rather than fixing anything.

The link-tap decision — follow in-app, explain we can't show it, or hand it to the
browser — lives in BioLinkFollower in Core rather than in the span, so all three
routes are tested, the manga branch included. What is left in BioLinkSpans is
genuinely device-bound: Apply needs a real Spanned, OnTouchEvent needs a
Layout, and the TextWatcher needs a live TextView. That file holds no
product decision.

Review notes

Scope is wider than the two issues — every addition was raised and agreed, but
the MediaDetailsPageModel change has the largest blast radius and is the one
worth a second look.

The second commit is coverage rather than behaviour: StaffDetailsPageModel had
received the same three changes as the character page while every test went to the
character side, and StaffDetailsPageModelTests had no coverage of the bio surface
at all. Since both issues are about both page types, that half had only ever been
checked by hand. It also moves the link-tap decision into Core so it can be tested,
and re-verifies on device afterwards, since that changed the click path.

Character and staff bios lost both their words and their shape. Markdown links
rendered as invisible gaps, and every paragraph break was discarded. Sampling the
50 most-favourited characters and staff put the scale of it beyond doubt: 42 of
50 bios contain at least one link, and 47 of 50 contain a paragraph break.

Links (#137)

Html.FromHtml turns each anchor into a URLSpan, which ignores the label's
TextColor and paints itself with the TextView's textColorLink. That resolves
through Theme.MaterialComponents.DayNight to colorAccent, which colors.xml sets
to transparent so the rainbow theming can show through — so link text painted
transparent while still taking up its own width.

BioLinkSpans swaps each URLSpan for a span that paints its own colour, which
sidesteps textColorLink rather than overriding it: colorAccent stays transparent
and the theming is untouched. Colour comes from the rainbow palette keyed on the
link text, via a ResourceKeyFor extracted from RainbowAccentConverter so both use
the same FNV-1a hash and a name always paints the same colour. Taps route in-app
through AniListLinkTarget, a pure Core function: anilist.co character, anime,
staff and studio links go to the matching page (162 of 235 sampled links),
everything else to IExternalBrowser.

Two things about the Android hook are worth knowing, because neither is visible
from the code. It must be registered under a custom mapper key: Label's
RemapForControls swaps LabelHandler.Mapper for a ControlsLabelMapper that defines
Text and TextType itself, off Label's static init during the first page render,
so a registration on those keys is shadowed and silently never runs — before or
after builder.Build(). And because a custom key only runs when the handler is
built, a TextWatcher re-applies the spans when the text changes; without it the
links go invisible again the first time spoilers are toggled. Touch handling is a
BaseMovementMethod rather than LinkMovementMethod, which extends
ScrollingMovementMethod and would steal vertical drags from the page's ScrollView.

Breaks (#138)

AniListMarkdownProcessor now emits <br> for every newline and a doubled break for
a blank line. Every newline becomes a break, lone ones included: AniList does not
hard-wrap prose — across the 50 sampled bios not one lone newline fell
mid-sentence — so a lone newline is always structure the author meant, most
visibly the bullet lists in staff bios. The patterns match \r?\n because
DescriptionParser builds prose with AppendLine, which is \n on Android and \r\n
under the Windows test run.

Truncation moved with it. IsTruncated was being handed the raw markdown, which
counts link URLs as visible text and by construction contains none of the break
tags the heuristic looks for, so that branch was dead on these pages; it now gets
the rendered BioProse. CharsPerLine drops 45 to 40, since the labels render at
Body2's 15sp rather than the 14sp the constant assumed. Where the estimate has to
be wrong it should now err towards a redundant "Read more" rather than silently
tail-truncating text the reader cannot reach. MediaDetailsPageModel carried its
own copy of the whole heuristic, still at 45, behind a label identical to the bio
ones; it now calls the shared helper, and a test pins it against the duplicate
returning.

Description parsing

Four defects found while verifying the above, all pre-existing:

- A ~!…!~ block spanning several stat rows only parsed in its single-line form,
  so the opening line failed, stat parsing ended early, and every row after it —
  spoiler or not — landed in the prose card. Character 40 lost three rows this way.
- __Height__: (colon outside the underscores) was not recognised. A miss on the
  first line latches the parser into prose, so those bios lost their entire stat
  card, later rows in the valid spelling included. 5 of 200 sampled, Naruto,
  Sasuke, Kurapika and Joseph Joestar among them.
- Stat row values never ran through the markdown processor, so a link in a value
  rendered as a literal [name](url) beside prose that rendered correctly.
- _single-underscore_ italics were unhandled, leaving underscores on screen in 9
  of 200 sampled bios.

Verification

The rendering half cannot be unit-tested, so all of it was checked on device
against the live API, signed out: link colour and taps, in-app routing, scrolling
over the bio, paragraph and list breaks, the spoiler toggle re-applying spans,
and both parser fixes. The string half is covered by 39 new tests; the bug fixes
were written red first.
Copilot AI lite review requested due to automatic review settings August 28, 2026 03:13
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

📱 UI Screenshots

✅ Authenticated UI — screenshots rendered via compile-time CI stub services with hardcoded data. No OAuth token required.

View Workflow Run →

Library Discover View All (Browse) Search One Piece Details Toei Animation (Studio) Luffy (Character) Mayumi Tanaka (Staff) Settings
Library Discover View All (Browse) Search One Piece Details Toei Animation (Studio) Luffy (Character) Mayumi Tanaka (Staff) Settings

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The updated DescriptionParser stat-line regex appears to stop matching the existing __Label:__ value format, which would regress stat-card parsing for real bios and existing tests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes character/staff bio rendering and interaction in AniSprinkles by preserving paragraph structure, making markdown links visible/tappable on Android, and tightening the “Read more” truncation logic so it reflects what the UI actually renders.

Changes:

  • Convert AniList bio newlines to <br> markup and extend markdown handling (e.g., underscore italics) so bios keep their intended shape (#138).
  • Add Android-side span replacement to recolor and route <a> links in bios without relying on theme textColorLink (#137), plus Core URL→route resolution.
  • Unify description truncation heuristics across details pages and update parsing/tests for stat rows and spoiler edge-cases.
File summaries
File Description
tests/AniSprinkles.UnitTests/MediaDetailsPageModelTests.cs Adds a regression test to ensure media details uses the shared truncation heuristic.
tests/AniSprinkles.UnitTests/DescriptionParserTests.cs Adds coverage for broader stat-row parsing and multi-line spoiler blocks.
tests/AniSprinkles.UnitTests/ConverterTests.cs Tests stability/behavior of shared rainbow accent resource key selection.
tests/AniSprinkles.UnitTests/CharacterDetailsPageModelTests.cs Adds tests for spoiler + <br> interactions, stat value markdown rendering, and truncation measured on rendered bio.
tests/AniSprinkles.UnitTests/AniListMarkdownProcessorTests.cs Adds tests for underscore italics and newline→<br> conversion contract.
tests/AniSprinkles.UnitTests/AniListLinkTargetTests.cs New tests for mapping AniList entity URLs to in-app routes and identifying unsupported entities.
src/AniSprinkles/Views/StaffDetailsLoadedContentView.xaml Renders stat values as HTML so processed markdown (including links) displays correctly.
src/AniSprinkles/Views/CharacterDetailsLoadedContentView.xaml Renders stat values as HTML so processed markdown (including links) displays correctly.
src/AniSprinkles/Platforms/Android/BioLinkSpans.cs New Android implementation to replace URLSpans with tappable, colored spans that route in-app or fall back appropriately.
src/AniSprinkles/MauiProgram.cs Registers Android Label handler mapping (custom key) to attach bio link span behavior.
src/AniSprinkles.Core/Utilities/DescriptionTruncationHeuristic.cs Recalibrates and documents the shared truncation heuristic (e.g., chars/line), and centralizes shared logic.
src/AniSprinkles.Core/Utilities/DescriptionParser.cs Extends stat-row parsing to accept additional label/colon spellings and multi-line spoiler blocks.
src/AniSprinkles.Core/Utilities/AniListMarkdownProcessor.cs Adds underscore italics and converts newlines to <br> markup after normalization.
src/AniSprinkles.Core/Utilities/AniListLinkTarget.cs New Core utility to resolve AniList URLs to app routes and identify unsupported entity links.
src/AniSprinkles.Core/PageModels/StaffDetailsPageModel.cs Measures truncation on rendered bio prose and processes stat values through markdown processor.
src/AniSprinkles.Core/PageModels/MediaDetailsPageModel.cs Removes duplicate truncation heuristic and uses shared helper/constants.
src/AniSprinkles.Core/PageModels/CharacterDetailsPageModel.cs Measures truncation on rendered bio prose and processes stat values through markdown processor.
src/AniSprinkles.Core/Converters/RainbowAccentConverter.cs Extracts and exposes ResourceKeyFor so Android span code can share the same deterministic mapping.
Review details
  • Files reviewed: 18/27 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Zach Hollis and others added 4 commits August 28, 2026 00:00
Two coverage gaps in the previous commit, found by auditing what it changed
against what it tested.

StaffDetailsPageModel got the same three changes as the character page —
truncation measured on the rendered bio, the spoiler renotification, and markdown
in stat row values — but every test went into CharacterDetailsPageModelTests and
StaffDetailsPageModelTests had no coverage of the bio surface at all. Since #137
and #138 are about both page types, and staff bios are the ones carrying the
Markdown lists and the links to agencies and other creators, that half was only
ever verified by hand on device. Six tests now cover it, including the __Label__:
spelling and a spoiler spanning a paragraph break.

The link-tap decision — follow in-app, explain we cannot show it, or hand it to
the browser — was inline in the Android span, so none of it could be tested,
including the manga branch, which is a product decision rather than a technical
constraint. It moves to BioLinkFollower in Core, with the span left holding only
the service lookup. Thirteen tests pin the three routes, the unusable-URL cases,
and the swallowed failure. The "not supported yet" message is now a shared
constant, so the bio toast and DetailsPageModelBase's cannot drift.

What stays untestable in BioLinkSpans is genuinely device-bound: Apply needs a
real Spanned, OnTouchEvent needs a Layout, and the TextWatcher needs a live
TextView. The file no longer holds any product decision.

1231 to 1250 tests. Re-verified on device after the extraction, since it changed
the click path: spans still applied (1 stat row, 6 prose on staff 96881) and a
tap still routes in-app.
ASpoilerSpanningPagagraphs -> ASpoilerSpanningParagraphs, matching the correctly
spelled sibling and the staff equivalent. Raised in review on #143.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

DescriptionParser.StatLineRegex currently will not match the existing __Label:__ value stat-row form, which would break real-world stat parsing and contradict existing tests/expectations.

Review details

Suppressed comments (1)

src/AniSprinkles.Core/Utilities/DescriptionParser.cs:26

  • StatLineRegex doesn’t match the existing stat-row spelling __Label:__ value (colon before the closing __). With the current pattern, parsing will fail on common bios (including the existing Luffy-shape test input) and will latch the rest of the description into prose, dropping the stat card.
    private static readonly Regex StatLineRegex = new(
        @"^__(?<label>[^_:]+)(?::__|__\s*:)\s*(?<value>.+?)\s*$",
        RegexOptions.Compiled);
  • Files reviewed: 22/31 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@zhollis21
zhollis21 merged commit 377f9f9 into main Aug 28, 2026
4 checks passed
@zhollis21
zhollis21 deleted the feature/137-138-bio-link-and-paragraph-rendering branch August 28, 2026 14:06
zhollis21 added a commit that referenced this pull request Nov 19, 2026
* Bio links, paragraph breaks, and description parsing (#137, #138)

Character and staff bios lost both their words and their shape. Markdown links
rendered as invisible gaps, and every paragraph break was discarded. Sampling the
50 most-favourited characters and staff put the scale of it beyond doubt: 42 of
50 bios contain at least one link, and 47 of 50 contain a paragraph break.

Links (#137)

Html.FromHtml turns each anchor into a URLSpan, which ignores the label's
TextColor and paints itself with the TextView's textColorLink. That resolves
through Theme.MaterialComponents.DayNight to colorAccent, which colors.xml sets
to transparent so the rainbow theming can show through — so link text painted
transparent while still taking up its own width.

BioLinkSpans swaps each URLSpan for a span that paints its own colour, which
sidesteps textColorLink rather than overriding it: colorAccent stays transparent
and the theming is untouched. Colour comes from the rainbow palette keyed on the
link text, via a ResourceKeyFor extracted from RainbowAccentConverter so both use
the same FNV-1a hash and a name always paints the same colour. Taps route in-app
through AniListLinkTarget, a pure Core function: anilist.co character, anime,
staff and studio links go to the matching page (162 of 235 sampled links),
everything else to IExternalBrowser.

Two things about the Android hook are worth knowing, because neither is visible
from the code. It must be registered under a custom mapper key: Label's
RemapForControls swaps LabelHandler.Mapper for a ControlsLabelMapper that defines
Text and TextType itself, off Label's static init during the first page render,
so a registration on those keys is shadowed and silently never runs — before or
after builder.Build(). And because a custom key only runs when the handler is
built, a TextWatcher re-applies the spans when the text changes; without it the
links go invisible again the first time spoilers are toggled. Touch handling is a
BaseMovementMethod rather than LinkMovementMethod, which extends
ScrollingMovementMethod and would steal vertical drags from the page's ScrollView.

Breaks (#138)

AniListMarkdownProcessor now emits <br> for every newline and a doubled break for
a blank line. Every newline becomes a break, lone ones included: AniList does not
hard-wrap prose — across the 50 sampled bios not one lone newline fell
mid-sentence — so a lone newline is always structure the author meant, most
visibly the bullet lists in staff bios. The patterns match \r?\n because
DescriptionParser builds prose with AppendLine, which is \n on Android and \r\n
under the Windows test run.

Truncation moved with it. IsTruncated was being handed the raw markdown, which
counts link URLs as visible text and by construction contains none of the break
tags the heuristic looks for, so that branch was dead on these pages; it now gets
the rendered BioProse. CharsPerLine drops 45 to 40, since the labels render at
Body2's 15sp rather than the 14sp the constant assumed. Where the estimate has to
be wrong it should now err towards a redundant "Read more" rather than silently
tail-truncating text the reader cannot reach. MediaDetailsPageModel carried its
own copy of the whole heuristic, still at 45, behind a label identical to the bio
ones; it now calls the shared helper, and a test pins it against the duplicate
returning.

Description parsing

Four defects found while verifying the above, all pre-existing:

- A ~!…!~ block spanning several stat rows only parsed in its single-line form,
  so the opening line failed, stat parsing ended early, and every row after it —
  spoiler or not — landed in the prose card. Character 40 lost three rows this way.
- __Height__: (colon outside the underscores) was not recognised. A miss on the
  first line latches the parser into prose, so those bios lost their entire stat
  card, later rows in the valid spelling included. 5 of 200 sampled, Naruto,
  Sasuke, Kurapika and Joseph Joestar among them.
- Stat row values never ran through the markdown processor, so a link in a value
  rendered as a literal [name](url) beside prose that rendered correctly.
- _single-underscore_ italics were unhandled, leaving underscores on screen in 9
  of 200 sampled bios.

Verification

The rendering half cannot be unit-tested, so all of it was checked on device
against the live API, signed out: link colour and taps, in-app routing, scrolling
over the bio, paragraph and list breaks, the spoiler toggle re-applying spans,
and both parser fixes. The string half is covered by 39 new tests; the bug fixes
were written red first.

* CI: Update UI screenshots [skip ci]

* Cover the staff bio surface and move the link-tap decision into Core

Two coverage gaps in the previous commit, found by auditing what it changed
against what it tested.

StaffDetailsPageModel got the same three changes as the character page —
truncation measured on the rendered bio, the spoiler renotification, and markdown
in stat row values — but every test went into CharacterDetailsPageModelTests and
StaffDetailsPageModelTests had no coverage of the bio surface at all. Since #137
and #138 are about both page types, and staff bios are the ones carrying the
Markdown lists and the links to agencies and other creators, that half was only
ever verified by hand on device. Six tests now cover it, including the __Label__:
spelling and a spoiler spanning a paragraph break.

The link-tap decision — follow in-app, explain we cannot show it, or hand it to
the browser — was inline in the Android span, so none of it could be tested,
including the manga branch, which is a product decision rather than a technical
constraint. It moves to BioLinkFollower in Core, with the span left holding only
the service lookup. Thirteen tests pin the three routes, the unusable-URL cases,
and the swallowed failure. The "not supported yet" message is now a shared
constant, so the bio toast and DetailsPageModelBase's cannot drift.

What stays untestable in BioLinkSpans is genuinely device-bound: Apply needs a
real Spanned, OnTouchEvent needs a Layout, and the TextWatcher needs a live
TextView. The file no longer holds any product decision.

1231 to 1250 tests. Re-verified on device after the extraction, since it changed
the click path: spans still applied (1 stat row, 6 prose on staff 96881) and a
tap still routes in-app.

* CI: Update UI screenshots [skip ci]

* Fix a typo in a test name

ASpoilerSpanningPagagraphs -> ASpoilerSpanningParagraphs, matching the correctly
spelled sibling and the staff equivalent. Raised in review on #143.

* CI: Update UI screenshots [skip ci]

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
zhollis21 added a commit that referenced this pull request Nov 19, 2026
Removing screenshots/ from main's history gave every commit a new SHA. The
four commits the create-issue and kickoff skills cite as examples now read
3fb0aa3 (#123), 3707476 (#135), 18d252a (#143) and 30ff33c (#61).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants