{"id":19260753,"url":"https://github.com/evant/spanalot","last_synced_at":"2025-04-21T16:32:11.061Z","repository":{"id":24026522,"uuid":"27411254","full_name":"evant/spanalot","owner":"evant","description":"A simple utility for creating and modifying spannables in Android","archived":false,"fork":false,"pushed_at":"2025-01-04T04:41:18.000Z","size":132,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T14:38:19.762Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evant.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}},"created_at":"2014-12-02T02:31:30.000Z","updated_at":"2025-01-04T04:36:00.000Z","dependencies_parsed_at":"2022-08-22T09:40:56.356Z","dependency_job_id":null,"html_url":"https://github.com/evant/spanalot","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/evant%2Fspanalot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fspanalot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fspanalot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evant%2Fspanalot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evant","download_url":"https://codeload.github.com/evant/spanalot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250091030,"owners_count":21373304,"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-11-09T19:22:46.039Z","updated_at":"2025-04-21T16:32:11.048Z","avatar_url":"https://github.com/evant.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"spanalot\n========\n\nA simple utility for creating and modifying AnnotateStrings/Spannables in Android\n\nThis may end up on maven central sometime in the future, in the mean time, it's just one class\nso you can copy-and-paste it into your project.\n\n- Compose (Annotated String): https://github.com/evant/spanalot/blob/main/spanalot-compose/src/main/java/me/tatarka/spanalot/Spanalot.kt\n- Spannable: https://github.com/evant/spanalot/blob/main/spanalot/src/main/java/me/tatarka/spanalot/Spanalot.java\n\n## Usage\n\n### Compose\n\n```kotlin\nimport me.tatarka.spanalot.*\n\n// Construct a new AnnotatedString.Builder with some global styles\nval spanalot = buildAnnotatedString(SpanStyle(color = colorResource(R.color.red_200))) {\n    // Append segments of text with styles that apply to them.\n    append(\"Hello, \", SpanStyle(fontStyle = FontStyle.Italic))\n    append(\"World!\", SpanStyle(color = colorResource(R.color.purple_900), fontSize = 1.5.em))\n}\n// And use it like normal\nText(spanalot)\n\n// You can format like String.format() too. Unlike String.format() AnnotatedString args are preserved!\nval spanalot = buildAnnotatedString(SpanStyle(color = colorResource(R.color.red_200))) {\n    appendFormat(\n        \"%1\\$s, %2\\$s!\",\n        AnnotatedString(\"Hello\", SpanStyle(fontStyle = FontStyle.Italic)),\n        AnnotatedString.fromHtml(\"\u003cb\u003eWorld\u003c/b\u003e\")\n    )\n}\n// Use AnnotatedString.format() for simpler cases.\nval spanalot = AnnotatedString.format(\"Hello, %s!\", AnnotatedString.fromHtml(\"\u003cb\u003eWorld\u003c/b\u003e\"))\n```\n\n### Java\n\n```java\nimport me.tatarka.spanalot.Spanalot;\nimport static me.tatarka.spanalot.Spanalot.*;\n\n// Construct a new spanalot with some global spans. \n// You can use the provided functions to simplify common spans.\nSpanalot spanalot = new Spanalot(backgroundColor(getResources().getColor(R.color.red_200)))\n        // Append segments of text with spans that apply to them.\n        .append(\"Hello, \", style(Typeface.ITALIC))\n        .append(\"World!\", textColor(getResources().getColor(R.color.purple_900)),\n                          textSizeRelative(1.5f),\n                          // You can use your own spans if you feel like it.\n                          new MyCustomSpanThatDoesWhatever());\n\n// Spanalot is just a Spanned, use it like one!\ntextView.setText(spanalot);\n\n// If you just need a single piece, you can use a more convienent constructor\ntextView.setText(new Spanalot(\"Hello, World!\", style(Typeface.ITALIC)));\n\n// You can format like String.format() too. Unlike String.format() spans are preserved!\nSpanalot spanalot = new Spanalot(backgroundColor(getResources().getColor(R.color.red_200)))\n        .format(\"%1$s, %2$s!\")\n        .arg(\"Hello\", style(Typeface.ITALIC))\n        // Any styled CharSequence will work.\n        .arg(Html.fromHtml(\"\u003cb\u003eWorld\u003c/b\u003e\"));\n```\n\nThat's it! What could be simpler?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevant%2Fspanalot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevant%2Fspanalot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevant%2Fspanalot/lists"}