{"id":17872567,"url":"https://github.com/gregors/sax_html","last_synced_at":"2025-03-21T19:32:58.901Z","repository":{"id":54387618,"uuid":"338718438","full_name":"gregors/sax_html","owner":"gregors","description":"SAX-like parser for HTML","archived":false,"fork":false,"pushed_at":"2021-02-21T19:05:30.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-23T16:17:39.167Z","etag":null,"topics":["sax","sax-parser"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregors.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-14T03:05:57.000Z","updated_at":"2023-05-23T23:34:05.000Z","dependencies_parsed_at":"2022-08-13T14:10:31.814Z","dependency_job_id":null,"html_url":"https://github.com/gregors/sax_html","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fsax_html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fsax_html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fsax_html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fsax_html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregors","download_url":"https://codeload.github.com/gregors/sax_html/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221818150,"owners_count":16885697,"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":["sax","sax-parser"],"created_at":"2024-10-28T10:43:25.802Z","updated_at":"2024-10-28T10:43:26.499Z","avatar_url":"https://github.com/gregors.png","language":"Elixir","readme":"# SaxHtml\n\nSimple SAX-like parser for HTML.\nIt accepts an html string and an anonymous callback function that fires for every event\n\n\n```elixir\nhtml_text = \"\"\"\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eGregors\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv\u003e\n      \u003cp\u003eHowdy!!!\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n\"\"\"\n\nhandler = fn {event, data, state} -\u003e IO.puts(\"#{event} - #{data}\") end\n\nSaxHtml.parse(html_text, handler)\nstart_tag - html\ncharacters -\n\nstart_tag - head\ncharacters -\n\nstart_tag - title\ncharacters - Gregors\nend_tag - title\ncharacters -\n\nend_tag - head\ncharacters -\n\nstart_tag - body\ncharacters -\n\nstart_tag - div\ncharacters -\n\nstart_tag - p\ncharacters - Howdy!!!\nend_tag - p\ncharacters -\n\nend_tag - div\ncharacters -\n\nend_tag - body\ncharacters -\n\nend_tag - html\ncharacters -\n```\n\nOr with `state`. State must be returned from the callback\n\n```\nhandler = fn\n  { :characters, chars, state} -\u003e [ chars | state ]\n  { _, _, state} -\u003e state\nend\n\nSaxHtml.parse(html_text, handler, []) |\u003e Enum.join(\"\") |\u003e IO.inspect\n\n\"\\n\\n\\n  \\n    Howdy!!!\\n      \\n    \\n  \\n  Gregors\\n    \\n  \"\n```\n\n\n## Installation\n\nThe package is [available in Hex](https://hex.pm/packages/sax_html), the package can be installed by adding `sax_html` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:sax_html, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregors%2Fsax_html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregors%2Fsax_html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregors%2Fsax_html/lists"}