{"id":17130390,"url":"https://github.com/swelham/social_parser","last_synced_at":"2025-04-13T06:32:10.457Z","repository":{"id":57550292,"uuid":"72485189","full_name":"swelham/social_parser","owner":"swelham","description":"A small library for parsing out common social elements such as hashtags, mentions and urls.","archived":false,"fork":false,"pushed_at":"2020-02-22T14:50:56.000Z","size":27,"stargazers_count":17,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T02:21:09.245Z","etag":null,"topics":["elixir","hashtag","mentions","parser","parsing","url"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swelham.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":"2016-10-31T23:00:50.000Z","updated_at":"2024-05-31T16:09:17.000Z","dependencies_parsed_at":"2022-09-10T08:51:55.611Z","dependency_job_id":null,"html_url":"https://github.com/swelham/social_parser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fsocial_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fsocial_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fsocial_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fsocial_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swelham","download_url":"https://codeload.github.com/swelham/social_parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674662,"owners_count":21143760,"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":["elixir","hashtag","mentions","parser","parsing","url"],"created_at":"2024-10-14T19:12:17.187Z","updated_at":"2025-04-13T06:32:10.177Z","avatar_url":"https://github.com/swelham.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SocialParser\n\n[![Join the chat at https://gitter.im/swelham/social_parser](https://badges.gitter.im/swelham/social_parser.svg)](https://gitter.im/swelham/social_parser?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Build Status](https://travis-ci.org/swelham/social_parser.svg?branch=master)](https://travis-ci.org/swelham/social_parser) [![Hex Version](https://img.shields.io/hexpm/v/social_parser.svg)](https://hex.pm/packages/social_parser)\n\nA small library for parsing out common social elements such as hashtags, mentions and urls.\n\n## Usage\n\nAdd `social_parser` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:social_parser, \"~\u003e 1.1.0\"}]\nend\n```\n\nYou can then parse out the social components like so:\n\n```elixir\ndefmodule SocialParserTest do\n  def do_social_stuff() do\n    message = \"hi @you checkout http://example.com/ that +someone hosted #example\"\n\n    # parse out all components into an array\n    components = SocialParser.parse(message)\n\n    IO.inspect(components)\n    # [\n    #   {:text, \"hi \", {0, 3}},\n    #   {:mention, \"@you\", {4, 8}},\n    #   {:text, \" checkout \", {9, 19}},\n    #   {:link, \"http://example.com/\", {20, 39}},\n    #   {:text, \" that \", {40, 46}},\n    #   {:mention, \"+someone\", {47, 55}},\n    #   {:text, \" hosted \", {56, 64}},\n    #   {:hashtag, \"#example\", {65, 73}}\n    # ]\n\n    # extract targeted components\n    some_components = SocialParser.extract(message, [:hashtags, :mentions])\n\n    IO.inspect(some_components)\n    #%{\n    #   hashtags: [\"#example\"],\n    #   mentions: [\"@you\", \"+someone\"]\n    #}\n  end\nend\n```\n\n# TODO\n\n* Merge the private `parse` and `parse_components` functions as there is some duplication of code\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswelham%2Fsocial_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswelham%2Fsocial_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswelham%2Fsocial_parser/lists"}