{"id":15286155,"url":"https://github.com/utgwkk/twitter-text","last_synced_at":"2026-01-06T04:03:45.416Z","repository":{"id":39228298,"uuid":"306001673","full_name":"utgwkk/Twitter-Text","owner":"utgwkk","description":"Perl implementation of the twitter-text parsing library","archived":false,"fork":false,"pushed_at":"2022-06-01T12:07:59.000Z","size":221,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-14T19:14:02.285Z","etag":null,"topics":["perl","twitter","twitter-text"],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/Twitter::Text","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utgwkk.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2020-10-21T11:27:16.000Z","updated_at":"2022-06-01T12:08:00.000Z","dependencies_parsed_at":"2022-09-07T11:50:46.734Z","dependency_job_id":null,"html_url":"https://github.com/utgwkk/Twitter-Text","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utgwkk%2FTwitter-Text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utgwkk%2FTwitter-Text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utgwkk%2FTwitter-Text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utgwkk%2FTwitter-Text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utgwkk","download_url":"https://codeload.github.com/utgwkk/Twitter-Text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245169928,"owners_count":20571980,"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":["perl","twitter","twitter-text"],"created_at":"2024-09-30T15:10:47.119Z","updated_at":"2026-01-06T04:03:45.317Z","avatar_url":"https://github.com/utgwkk.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/utgwkk/Twitter-Text/workflows/CI/badge.svg)](https://github.com/utgwkk/Twitter-Text/actions)\n# NAME\n\nTwitter::Text - Perl implementation of the twitter-text parsing library\n\n# SYNOPSIS\n\n    use Twitter::Text;\n\n    $result = parse_tweet('Hello world こんにちは世界');\n    print $result-\u003e{valid} ? 'valid tweet' : 'invalid tweet';\n\n# DESCRIPTION\n\nTwitter::Text is a Perl implementation of the twitter-text parsing library.\n\n## WARNING\n\nThis library does not implement auto-linking and hit highlighting.\n\nPlease refer [Implementation status](https://github.com/utgwkk/Twitter-Text/issues/5) for latest status.\n\n# FUNCTIONS\n\nAll functions below are exported by default.\n\n## Extraction\n\n### extract\\_hashtags\n\n    $hashtags = extract_hashtags($text);\n\nReturns an array reference of extracted hashtag string from `$text`.\n\n### extract\\_hashtags\\_with\\_indices\n\n    $hashtags_with_indices = extract_hashtags_with_indices($text, [\\%options]);\n\nReturns an array reference of hash reference of extracted hashtag from `$text`.\n\nEach hash reference consists of `hashtag` (hashtag string) and `indices` (range of hashtag).\n\n### extract\\_mentioned\\_screen\\_names\n\n    $screen_names = extract_mentioned_screen_names($text);\n\nReturns an array reference of exctacted screen name string from `$text`.\n\n### extract\\_mentioned\\_screen\\_names\\_with\\_indices\n\n    $screen_names_with_indices = extract_mentioned_screen_names_with_indices($text);\n\nReturns an array reference of hash reference of extracted screen name or list from `$text`.\n\nEach hash reference consists of `screen_name` (screen name string) and `indices` (range of screen name).\n\n### extract\\_mentions\\_or\\_lists\\_with\\_indices\n\n    $mentions_or_lists_with_indices = extract_mentions_or_lists_with_indices($text);\n\nReturns an array reference of hash reference of extracted screen name from `$text`.\n\nEach hash reference consists of `screen_name` (screen name string) and `indices` (range of screen name or list). If it is a list, the hash reference also contains `list_slug` item.\n\n### extract\\_urls\n\n    $urls = extract_urls($text);\n\nReturns an array reference of extracted URL string from `$text`.\n\n### extract\\_urls\\_with\\_indices\n\n    $urls = extract_urls_with_indices($text, [\\%options]);\n\nReturns an array reference of hash reference of extracted URL from `$text`.\n\nEach hash reference consists of `url` (URL string) and `indices` (range of screen name).\n\n## Validation\n\n### parse\\_tweet\n\n    $parse_result = parse_tweet($text, [\\%options]);\n\nThe `parse_tweet` function takes a `$text` string and optional `\\%options` parameter and returns a hash reference with following values:\n\n- `weighted_length`\n\n    The overall length of the tweet with code points weighted per the ranges defined in the configuration file.\n\n- `permillage`\n\n    Indicates the proportion (per thousand) of the weighted length in comparison to the max weighted length. A value \u003e 1000 indicates input text that is longer than the allowable maximum.\n\n- `valid`\n\n    Indicates if input text length corresponds to a valid result.\n\n- `display_range_start`, `display_range_end`\n\n    An array of two unicode code point indices identifying the inclusive start and exclusive end of the displayable content of the Tweet.\n\n- `valid_range_start`, `valid_range_end`\n\n    An array of two unicode code point indices identifying the inclusive start and exclusive end of the valid content of the Tweet.\n\n#### EXAMPLES\n\n    use Data::Dumper;\n    use Twitter::Text;\n\n    $result = parse_tweet('Hello world こんにちは世界');\n    print Dumper($result);\n    # $VAR1 = {\n    #       'weighted_length' =\u003e 33\n    #       'permillage' =\u003e 117,\n    #       'valid' =\u003e 1,\n    #       'display_range_start' =\u003e 0,\n    #       'display_range_end' =\u003e 32,\n    #       'valid_range_start' =\u003e 0,\n    #       'valid_range_end' =\u003e 32,\n    #     };\n\n### is\\_valid\\_hashtag\n\n    $valid = is_valid_hashtag($hashtag);\n\nValidate `$hashtag` is a valid hashtag and returns a boolean value that indicates if given argument is valid.\n\n### is\\_valid\\_list\n\n    $valid = is_valid_list($username_list);\n\nValidate `$username_list` is a valid @username/list and returns a boolean value that indicates if given argument corresponds to a valid result.\n\n### is\\_valid\\_url\n\n    $valid = is_valid_url($url, [unicode_domains =\u003e 1, require_protocol =\u003e 1]);\n\nValidate `$url` is a valid URL and returns a boolean value that indicates if given argument is valid.\n\nIf `unicode_domains` argument is a truthy value, validate `$url` is a valid URL with Unicode characters. (default: true)\n\nIf `require_protocol` argument is a truthy value, validation requires a protocol of URL. (default: true)\n\n### is\\_valid\\_username\n\n    $valid = is_valid_username($username);\n\nValidate `$username` is a valid username for Twitter and returns a boolean value that indicates if given argument is valid.\n\n# SEE ALSO\n\n[twitter-text](https://github.com/twitter/twitter-text). Implementation of Twitter::Text (this library) is heavily based on [Ruby implementation of twitter-text](https://github.com/twitter/twitter-text/tree/master/rb).\n\n[https://developer.twitter.com/en/docs/counting-characters](https://developer.twitter.com/en/docs/counting-characters)\n\n# COPYRIGHT \u0026 LICENSE\n\nCopyright (C) Twitter, Inc and other contributors\n\nCopyright (C) utgwkk.\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# AUTHOR\n\nutgwkk \u003cutagawakiki@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futgwkk%2Ftwitter-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futgwkk%2Ftwitter-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futgwkk%2Ftwitter-text/lists"}