html-escape-0.2.12/.cargo_vcs_info.json 0000644 00000000136 00000000001 0013320 0 ustar {
"git": {
"sha1": "e2e292822bf157029980be4de0b35795fc657c47"
},
"path_in_vcs": ""
} html-escape-0.2.12/Cargo.toml 0000644 00000002377 00000000001 0011327 0 ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
name = "html-escape"
version = "0.2.12"
authors = ["Magic Len "]
include = [
"src/**/*",
"Cargo.toml",
"README.md",
"LICENSE",
"benches/encode.rs",
]
description = "This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well."
homepage = "https://magiclen.org/html-escape"
readme = "README.md"
keywords = [
"html",
"escape",
"unescape",
"encode",
"decode",
]
categories = [
"no-std",
"encoding",
]
license = "MIT"
repository = "https://github.com/magiclen/html-escape"
[[bench]]
name = "encode"
harness = false
required-features = ["std"]
[dependencies.utf8-width]
version = "0.1"
[dev-dependencies.bencher]
version = "0.1.5"
[features]
default = ["std"]
std = []
html-escape-0.2.12/Cargo.toml.orig 0000644 00000001342 00000000001 0012255 0 ustar [package]
name = "html-escape"
version = "0.2.12"
authors = ["Magic Len "]
edition = "2021"
repository = "https://github.com/magiclen/html-escape"
homepage = "https://magiclen.org/html-escape"
keywords = ["html", "escape", "unescape", "encode", "decode"]
categories = ["no-std", "encoding"]
description = "This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well."
readme = "README.md"
license = "MIT"
include = ["src/**/*", "Cargo.toml", "README.md", "LICENSE", "benches/encode.rs"]
[dependencies]
utf8-width = "0.1"
[dev-dependencies]
bencher = "0.1.5"
[features]
default = ["std"]
std = []
[[bench]]
name = "encode"
required-features = ["std"]
harness = false html-escape-0.2.12/Cargo.toml.orig 0000644 0000000 0000000 00000001342 10461020230 0014777 0 ustar 0000000 0000000 [package]
name = "html-escape"
version = "0.2.12"
authors = ["Magic Len "]
edition = "2021"
repository = "https://github.com/magiclen/html-escape"
homepage = "https://magiclen.org/html-escape"
keywords = ["html", "escape", "unescape", "encode", "decode"]
categories = ["no-std", "encoding"]
description = "This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well."
readme = "README.md"
license = "MIT"
include = ["src/**/*", "Cargo.toml", "README.md", "LICENSE", "benches/encode.rs"]
[dependencies]
utf8-width = "0.1"
[dev-dependencies]
bencher = "0.1.5"
[features]
default = ["std"]
std = []
[[bench]]
name = "encode"
required-features = ["std"]
harness = false html-escape-0.2.12/LICENSE 0000644 0000000 0000000 00000002066 10461020230 0013121 0 ustar 0000000 0000000 MIT License
Copyright (c) 2020 magiclen.org (Ron Li)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
html-escape-0.2.12/README.md 0000644 0000000 0000000 00000004100 10461020230 0013362 0 ustar 0000000 0000000 HTML Escape
====================
[](https://github.com/magiclen/html-escape/actions/workflows/ci.yml)
This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well.
## Usage
### Encoding
This crate provides some `encode_*` functions to encode HTML text in different situations.
For example, to put a text between a start tag `` and an end tag ``, use the `encode_text` function to escape every `&`, `<`, and `>` in the text.
```rust
assert_eq!("a > b && a < c", html_escape::encode_text("a > b && a < c"));
```
The functions suffixed with `_to_writer`, `_to_vec` or `_to_string` are useful to generate HTML.
```rust
let mut html = String::from("", &mut html));
html.push_str("');");
assert_eq!("", html);
```
### Decoding
```rust
assert_eq!("Hello world!", html_escape::decode_html_entities("Hello world!"));
```
```rust
assert_eq!("alert(');'", html_escape::decode_script(r"alert('`
parse_script;
/// Decode text from the ``
/// * `\'` => `'`
parse_script_single_quoted_text;
/// Decode text from a single quoted text in the ``
/// * `\"` => `"`
parse_script_double_quoted_text;
/// Decode text from a double quoted text in the ``
/// * `\"` => `"`
/// * `\'` => `'`
parse_script_quoted_text;
/// Decode text from a quoted text in the `` => `<\/script>`
parse_script;
/// Encode text used in the `` => `<\/script>`
/// * `'` => `\'`
parse_script_single_quoted_text;
/// Encode text used in a single quoted text in the `` => `<\/script>`
/// * `"` => `\"`
parse_script_double_quoted_text;
/// Encode text used in a double quoted text in the `` => `<\/script>`
/// * `"` => `\"`
/// * `'` => `\'`
parse_script_quoted_text;
/// Encode text used in a quoted text in the `", &mut html));
html.push_str("');");
assert_eq!("", html);
```
### Decoding
```rust
assert_eq!("Hello world!", html_escape::decode_html_entities("Hello world!"));
```
```rust
assert_eq!("alert('');", html_escape::decode_script(r"alert('