Repository navigation
Move Text(format:) to Swift Regex - #20
Merged
Merged
Conversation
The initializer used HandyRegex, which HandySwift deprecated, so every build showed two deprecation warnings. It now uses a Swift Regex literal, which also removes the fatalError for an unexpected capture count. The parts are still joined with Text's + operator: it is only deprecated once the deployment target reaches iOS 26, and interpolating the parts into a LocalizedStringKey instead shows placeholder characters under Xcode's pseudolanguages. Tests compare the rendering pixel by pixel against texts concatenated by hand.
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.
Overview
Text(format:partialStyling:)usedHandyRegex, which HandySwift deprecated, so every build of the package showed two deprecation warnings. It now uses a Swift Regex literal, which also removes thefatalErrorfor an unexpected capture count. Rendering is unchanged.The parts are still joined with Text's
+. Interpolating them into oneLocalizedStringKeyinstead was considered, as+is deprecated once the deployment target reaches iOS 26, but under Xcode's "Double-Length Pseudolanguage" that version renders@@@@@placeholders in front of the text.+does not warn at the package's current minimum, so it stays until the minimum reaches 26.Split out of #7.
How this was verified
TextFormatTestscomparesText(format:)pixel by pixel with texts concatenated by hand: plain text, paired tags, symbol tags, unknown and mismatched tags, and percent signs.main'sTextExt.swiftall 5 tests pass too, which shows the rendering did not change.pairedTags,unknownAndMismatchedTagsStayLiteralandtextWithPercentSignsfail.mainbuilds with'init(_:options:)' is deprecatedand'matches(in:)' is deprecatedinTextExt.swift; this branch buildsTextExt.swiftwithout warnings.