Skip to content

Fix/issue 83 localization parsing - #84

Merged
MarTrepodi merged 2 commits into
mainfrom
fix/issue-83-localization-parsing
Apr 15, 2026
Merged

Fix/issue 83 localization parsing#84
MarTrepodi merged 2 commits into
mainfrom
fix/issue-83-localization-parsing

Conversation

@MarTrepodi

Copy link
Copy Markdown
Collaborator

Description

Update tokenization of localization string parser to more completely cover all possible formatting.

Related Issues

Closes #83

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Documentation
  • Tests

Checklist

  • My commits follow the Angular commit convention (feat:, fix:, refactor:, etc.)
  • I have added/updated docstrings with type hints for any new or changed public methods
  • I have added unit tests that cover my changes (mocked, not requiring a live comlink service)
  • All existing tests still pass (python -m pytest tests/ -v)
  • Ruff linter passes (ruff check src/ tests/)
  • I have not bundled unrelated changes in this PR

Testing

Tested via existing and expanded unit tests as well as manual spot tests in Python REPL

…on bundle calls

docs(helpers): document parse_swgoh_string and its extended tag grammar
chore: add commitlint config and ignore .pythonrc.py
fix(helpers): extend parse_swgoh_string to cover full NGUI tag set (#83)


Adds a TestParseSwgohStringIssue83Coverage class that exercises every tag
and every color literal length called out in the issue across the output
formats where they are renderable but were previously untested:

- [t]/[/t] sprite, [y=X]/[/y] scale, [sub], [sub=X], [sup], [sup=X] in
  terminal/discord (must strip cleanly, no markup leakage)
- 4-digit [RGBA] in bare and terminal (RGB channel emitted, alpha dropped)
- 8-digit [RRGGBBAA] in bare, terminal, and web (web uses rgba() with the
  alpha channel converted to the 0-1 CSS float)
- 1-digit [A] alpha-only literal in terminal (re-emits the prior RGB)
- Standalone color literal in web with no enclosing [c] wrapper

Adding the web standalone-color test surfaced a latent bug: the web
finalizer never closed dangling spans/tags. _finalize_output now balances
any open color span and unclosed bold/italic/underline/strike depth so
strings that omit closing tags still produce well-formed HTML.

Total localization tests: 89 (was 77).
@MarTrepodi MarTrepodi self-assigned this Apr 15, 2026
@MarTrepodi MarTrepodi added bug Unintended functionality or behavior documentation Improvements or additions to documentation test Test related tasks labels Apr 15, 2026
@MarTrepodi
MarTrepodi merged commit 211494a into main Apr 15, 2026
15 of 16 checks passed
@MarTrepodi
MarTrepodi deleted the fix/issue-83-localization-parsing branch April 15, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended functionality or behavior code documentation Improvements or additions to documentation test Test related tasks testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Helpers] Localization string parsing does not handle every case

1 participant