{"id":16683673,"url":"https://github.com/apollozhu/rubyattribute","last_synced_at":"2025-06-12T12:35:00.363Z","repository":{"id":82774416,"uuid":"468682547","full_name":"ApolloZhu/RubyAttribute","owner":"ApolloZhu","description":"CTRubyAnnotation + AttributedString","archived":false,"fork":false,"pushed_at":"2022-03-11T10:29:07.000Z","size":13,"stargazers_count":26,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T01:14:14.810Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ApolloZhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-11T09:15:11.000Z","updated_at":"2024-11-21T03:01:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c45d0d3-ed9c-4678-b616-6ba2551d0e3a","html_url":"https://github.com/ApolloZhu/RubyAttribute","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApolloZhu%2FRubyAttribute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApolloZhu%2FRubyAttribute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApolloZhu%2FRubyAttribute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApolloZhu%2FRubyAttribute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ApolloZhu","download_url":"https://codeload.github.com/ApolloZhu/RubyAttribute/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248127582,"owners_count":21052253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T14:25:44.050Z","updated_at":"2025-04-09T23:25:14.384Z","avatar_url":"https://github.com/ApolloZhu.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RubyAttribute\n\nCTRubyAnnotation + AttributedString\n\n![What is the cat doing here? with ruby annotations on the word cat](https://user-images.githubusercontent.com/10842684/157847662-0e418f2a-3142-4bbd-9c9e-979bd586cc50.png)\n\n## Why Display in UILabel + NSAttributedString\n\n0. Foundation/SwiftUI/UIKit/CoreText forgot to add `kCTRubyAnnotationAttributeName` to `AttributedString` (FB9953514)\n1. SwiftUI `Text` ignores custom attributes\n2. `UITextView` doesn't work because reasons\n\n\u003e Note: remember adding `including: \\.coreText` when constructing `NSAttributedString` or else it will ignore custom attributes as well.\n\n## Usage\n\nConstruct AttributedString directly:\n\n```swift\nvar attributes = AttributeContainer()\nattributes.rubyAnnotation = .makeRubyAnnotation(text: [.before: \"ねこ\"])\nlet attributedString = AttributedString(\"猫\", attributes: attributes)\n```\n\n... or from markdown:\n\n```swift\n// defaults to before\ntry AttributedString(\n    markdown: \"^[猫](CTRubyAnnotation: 'ねこ')\",\n    including: \\.coreText,\n    options: .init(allowsExtendedAttributes: true)\n)\n\n// but you can specify where exactly, or even multiple positions\nAttributedString(localized:\n\"\"\"\nThe ^[猫](CTRubyAnnotation: {interCharacter: 'ㄇㄠ', after: 'cat'}) \\\nis seeking adoption.\n\"\"\", including: \\.coreText)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapollozhu%2Frubyattribute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapollozhu%2Frubyattribute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapollozhu%2Frubyattribute/lists"}