{"id":17694557,"url":"https://github.com/lomirus/html_editor","last_synced_at":"2025-04-26T23:38:08.838Z","repository":{"id":53093534,"uuid":"443542611","full_name":"lomirus/html_editor","owner":"lomirus","description":"Pure and simple HTML parser and editor.","archived":false,"fork":false,"pushed_at":"2023-11-15T03:00:29.000Z","size":88,"stargazers_count":26,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-26T19:30:54.768Z","etag":null,"topics":["html","parser","rust","xml"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/html_editor","language":"HTML","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/lomirus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-01-01T13:17:54.000Z","updated_at":"2025-01-11T20:08:21.000Z","dependencies_parsed_at":"2022-09-03T08:24:02.052Z","dependency_job_id":"a5c44caf-3663-4583-9fdb-ff37e1adc44b","html_url":"https://github.com/lomirus/html_editor","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":"0.015873015873015928","last_synced_commit":"a4b0e83de08fb8c775c0447a4a3c3d3a14d85640"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lomirus%2Fhtml_editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lomirus%2Fhtml_editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lomirus%2Fhtml_editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lomirus%2Fhtml_editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lomirus","download_url":"https://codeload.github.com/lomirus/html_editor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251051430,"owners_count":21528787,"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":["html","parser","rust","xml"],"created_at":"2024-10-24T13:49:06.032Z","updated_at":"2025-04-26T23:38:08.822Z","avatar_url":"https://github.com/lomirus.png","language":"HTML","readme":"[![crate-badge]][crate-link]\n[![downloads-badge]][crate-link]\n![License](https://img.shields.io/crates/l/html_editor)\n[![check-badge]][check-link]\n\n[crate-badge]: https://img.shields.io/crates/v/html_editor\n[crate-link]: https://crates.io/crates/html_editor\n[check-badge]: https://github.com/lomirus/html-editor/workflows/check/badge.svg\n[check-link]: https://github.com/lomirus/html-editor/actions/workflows/check.yaml\n[downloads-badge]: https://img.shields.io/crates/d/html_editor\n\n# HTML Editor\n\nPure and simple HTML parser and editor.\n\n## Examples\n\n### Parse HTML segment/document\n\n```rust\nlet document: Vec\u003cNode\u003e = parse(\"\u003c!doctype html\u003e\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e\")?;\nprintln!(\"{:#?}\", document);\n```\n\nOutput:\n\n```rust\n[\n    Doctype(\n        Html,\n    ),\n    Element {\n        name: \"html\",\n        attrs: {},\n        children: [\n            Element {\n                name: \"head\",\n                attrs: {},\n                children: [],\n            },\n            Element {\n                name: \"body\",\n                attrs: {},\n                children: [],\n            },\n        ],\n    },\n]\n```\n\nYou can also use `try_parse` to parse the html which contains tolerable errors\n\n```rust\nlet document: Vec\u003cNode\u003e = try_parse(\"\u003cdiv\u003e\u003cspan\u003eIpsum\u003c/div\u003e\");\n```\n\n### Query an element / elements by selector\n\n```rust\n// let html = r#\"...\"#\nlet nodes: Vec\u003cNode\u003e = parse(html)?;\nlet selector: Selector = Selector::from(\".box\");\n\nlet element: Option\u003cElement\u003e = nodes.query(\u0026selector);\nlet elements: Vec\u003cElement\u003e = nodes.query_all(\u0026selector);\n```\n\n### Edit the HTML\n\n```rust\n// let html = r#\"...\"#\nlet a: String = parse(html)?.trim().html();\nlet b: String = parse(html)?.insert_to(\u0026selector, node).html();\nlet c: String = parse(html)?.remove_by(\u0026selector).html();\nlet d: String = parse(html)?.replace_with(\u0026selector, |el| Node::Comment(el.html())).html();\n```\n\nYou can find more examples in the [documentation](https://docs.rs/html_editor/latest/html_editor/).\n\n## Changelog\n\nSee in [CHANGELOG.md](CHANGELOG.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flomirus%2Fhtml_editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flomirus%2Fhtml_editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flomirus%2Fhtml_editor/lists"}