{"id":13998153,"url":"https://github.com/magiclen/html-escape","last_synced_at":"2025-04-09T13:06:02.031Z","repository":{"id":39339358,"uuid":"275158556","full_name":"magiclen/html-escape","owner":"magiclen","description":"This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well.","archived":false,"fork":false,"pushed_at":"2024-06-17T13:53:28.000Z","size":237,"stargazers_count":44,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T07:51:21.656Z","etag":null,"topics":["escape","html","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/magiclen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-26T13:08:45.000Z","updated_at":"2025-03-19T20:39:46.000Z","dependencies_parsed_at":"2024-01-15T19:44:07.222Z","dependency_job_id":"cb5cd3ed-7575-4b0d-ad58-d944aa407c66","html_url":"https://github.com/magiclen/html-escape","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"93173c50ca404f3d473df4b12f77714a1d88c79c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fhtml-escape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fhtml-escape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fhtml-escape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fhtml-escape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/html-escape/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"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":["escape","html","rust"],"created_at":"2024-08-09T19:01:25.982Z","updated_at":"2025-04-09T13:06:02.008Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","readme":"HTML Escape\n====================\n\n[![CI](https://github.com/magiclen/html-escape/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/html-escape/actions/workflows/ci.yml)\n\nThis library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well.\n\n## Usage\n\n### Encoding\n\nThis crate provides some `encode_*` functions to encode HTML text in different situations.\n\nFor example, to put a text between a start tag `\u003cfoo\u003e` and an end tag `\u003c/foo\u003e`, use the `encode_text` function to escape every `\u0026`, `\u003c`, and `\u003e` in the text.\n\n```rust\nassert_eq!(\"a \u0026gt; b \u0026amp;\u0026amp; a \u0026lt; c\", html_escape::encode_text(\"a \u003e b \u0026\u0026 a \u003c c\"));\n```\n\nThe functions suffixed with `_to_writer`, `_to_vec` or `_to_string` are useful to generate HTML.\n\n```rust\nlet mut html = String::from(\"\u003cinput value=\");\nassert_eq!(\"Hello\u0026#x20;world\u0026#x21;\", html_escape::encode_unquoted_attribute_to_string(\"Hello world!\", \u0026mut html));\nhtml.push_str(\" placeholder=\\\"\");\nassert_eq!(\"The default value is \u0026quot;Hello world!\u0026quot;.\", html_escape::encode_double_quoted_attribute_to_string(\"The default value is \\\"Hello world!\\\".\", \u0026mut html));\nhtml.push_str(\"\\\"/\u003e\u003cscript\u003ealert('\");\nassert_eq!(r\"\u003cscript\u003e\\'s end tag is \u003c\\/script\u003e\", html_escape::encode_script_single_quoted_text_to_string(\"\u003cscript\u003e's end tag is \u003c/script\u003e\", \u0026mut html));\nhtml.push_str(\"');\u003c/script\u003e\");\n\nassert_eq!(\"\u003cinput value=Hello\u0026#x20;world\u0026#x21; placeholder=\\\"The default value is \u0026quot;Hello world!\u0026quot;.\\\"/\u003e\u003cscript\u003ealert(\\'\u003cscript\u003e\\\\\\'s end tag is \u003c\\\\/script\u003e\\');\u003c/script\u003e\", html);\n```\n\n### Decoding\n\n```rust\nassert_eq!(\"Hello world!\", html_escape::decode_html_entities(\"Hello\u0026#x20;world\u0026#x21;\"));\n```\n\n```rust\nassert_eq!(\"alert('\u003cscript\u003e\u003c/script\u003e);'\", html_escape::decode_script(r\"alert('\u003cscript\u003e\u003c\\/script\u003e);'\"));\n```\n\n## No Std\n\nDisable the default features to compile this crate without std.\n\n```toml\n[dependencies.html-escape]\nversion = \"*\"\ndefault-features = false\n```\n\n## Benchmark\n\n```bash\ncargo bench\n```\n\n## Crates.io\n\nhttps://crates.io/crates/html-escape\n\n## Documentation\n\nhttps://docs.rs/html-escape\n\n## License\n\n[MIT](LICENSE)","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fhtml-escape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fhtml-escape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fhtml-escape/lists"}