Repository navigation
Conversation
Add :libs:text-format, a pure-Kotlin KMP module that parses chat markup (bold, italic, strike, code, code blocks, quotes, lists, masked links) into display text, styled spans and display ranges. Word-character classes come from a generated Unicode 16.0.0 table so the JVM and iOS classify identically. The module is exported from :kmp:shared-core. The parser reads the 122 vectors of text_format.json from one commonTest, which runs on the JVM and the iOS simulator target.
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
:libs:text-format, a pure-Kotlin KMP module with one entry point,parseTextFormat(text, ranges). It turns chat markup (*bold*,_italic_,~strike~,`code`, code blocks,>quotes,-/1.lists,[text](url)masked links) into the display text, styled spans and moved link/mention ranges. Rules are in the chat text-formatting spec, code-payments/flipcash-client-orchestrator#39. The parser exists once so Android and iOS cannot disagree character for character; iOS gets it through the SharedCore XCFramework.ProtectedRangeinput,FormattedTextoutput; offsets are UTF-16 code units. Link and mention detection stay in:apps:flipcash:shared:chat; the parser never detects either.TextFormatUnicode.ktand its test, generated bytest-vectors/gen_text_format_unicode.py(Unicode 16.0.0) from the orchestrator repo. Both files are committed as generated.text_format.json(122 vectors) is copied byte for byte intosrc/commonTest/resources. One commonTest asserts every vector'sdisplay,spansanddisplayRanges, and a second test pins the file's sha256 so a stale copy fails.:libs:text-formatis registered insettings.gradle.kts, added to thekmpUnitTestModuleslist, and exported andapi'd from:kmp:shared-core.shared-core-tests.ymlnow runs itsiosSimulatorArm64Testand watcheslibs/text-format/**../gradlew :libs:text-format:allTestspasses ontestAndroidHostTest,iosSimulatorArm64TestandmacosArm64Test.:kmp:shared-core:assembleSharedCoreReleaseXCFrameworkbuilds. Changing onedisplayvalue in the copied fixture fails both vector tests.Nothing consumes the module yet.
ChatViewModel,buildMentionedText, the mention-pattern change and the link-detector trailing-marker cases are separate PRs.