markup5ever_rcdom-0.35.0+unofficial/.cargo_vcs_info.json 0000644 00000000166 00000000001 0016671 0 ustar {
"git": {
"sha1": "464118468457fde7ade8b511cdfa5588f8a10f41",
"dirty": true
},
"path_in_vcs": "rcdom"
} markup5ever_rcdom-0.35.0+unofficial/Cargo.lock 0000644 00000043034 00000000001 0014645 0 ustar # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
dependencies = [
"anstyle",
"once_cell",
"windows-sys",
]
[[package]]
name = "autocfg"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "bitflags"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"humantime",
"is-terminal",
"log",
"regex",
"termcolor",
]
[[package]]
name = "escape8259"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6"
[[package]]
name = "futf"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843"
dependencies = [
"mac",
"new_debug_unreachable",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e"
[[package]]
name = "html5ever"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55d958c2f74b664487a2035fe1dadb032c48718a03b63f3ab0b8537db8549ed4"
dependencies = [
"log",
"markup5ever",
"match_token",
]
[[package]]
name = "humantime"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f"
[[package]]
name = "is-terminal"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
dependencies = [
"hermit-abi",
"libc",
"windows-sys",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "libc"
version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "libtest-mimic"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33"
dependencies = [
"anstream",
"anstyle",
"clap",
"escape8259",
]
[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[package]]
name = "mac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "markup5ever"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "311fe69c934650f8f19652b3946075f0fc41ad8757dbb68f1ca14e7900ecc1c3"
dependencies = [
"log",
"tendril",
"web_atoms",
]
[[package]]
name = "markup5ever_rcdom"
version = "0.35.0+unofficial"
dependencies = [
"env_logger",
"html5ever",
"libtest-mimic",
"markup5ever",
"serde_json",
"tendril",
"xml5ever",
]
[[package]]
name = "match_token"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac84fd3f360fcc43dc5f5d186f02a94192761a080e8bc58621ad4d12296a58cf"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "new_debug_unreachable"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "once_cell"
version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]]
name = "phf"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
dependencies = [
"phf_shared",
]
[[package]]
name = "phf_codegen"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a"
dependencies = [
"phf_generator",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
dependencies = [
"phf_shared",
"rand",
]
[[package]]
name = "phf_shared"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
dependencies = [
"siphasher",
]
[[package]]
name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "proc-macro2"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "redox_syscall"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1"
dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "ryu"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
name = "siphasher"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
[[package]]
name = "smallvec"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[package]]
name = "string_cache"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "938d512196766101d333398efde81bc1f37b00cb42c2f8350e5df639f040bbbe"
dependencies = [
"new_debug_unreachable",
"parking_lot",
"phf_shared",
"precomputed-hash",
"serde",
]
[[package]]
name = "string_cache_codegen"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0"
dependencies = [
"phf_generator",
"phf_shared",
"proc-macro2",
"quote",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tendril"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0"
dependencies = [
"futf",
"mac",
"utf-8",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "utf-8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "web_atoms"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57ffde1dc01240bdf9992e3205668b235e59421fd085e8a317ed98da0178d414"
dependencies = [
"phf",
"phf_codegen",
"string_cache",
"string_cache_codegen",
]
[[package]]
name = "winapi-util"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "xml5ever"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee3f1e41afb31a75aef076563b0ad3ecc24f5bd9d12a72b132222664eb76b494"
dependencies = [
"log",
"markup5ever",
]
markup5ever_rcdom-0.35.0+unofficial/Cargo.toml 0000644 00000004335 00000000001 0014671 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 = "markup5ever_rcdom"
version = "0.35.0+unofficial"
authors = ["The html5ever Project Developers"]
build = false
publish = true
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Basic, unsupported DOM structure for use by tests in html5ever/xml5ever"
documentation = "https://docs.rs/markup5ever_rcdom"
readme = "README.md"
categories = [
"parser-implementations",
"web-programming",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/servo/html5ever"
[lib]
name = "markup5ever_rcdom"
path = "lib.rs"
[[example]]
name = "hello_xml"
path = "examples/hello_xml.rs"
[[example]]
name = "html2html"
path = "examples/html2html.rs"
[[example]]
name = "print-rcdom"
path = "examples/print-rcdom.rs"
[[example]]
name = "xml_tree_printer"
path = "examples/xml_tree_printer.rs"
[[test]]
name = "html-driver"
path = "tests/html-driver.rs"
[[test]]
name = "html-serializer"
path = "tests/html-serializer.rs"
[[test]]
name = "html-tokenizer"
path = "tests/html-tokenizer.rs"
harness = false
[[test]]
name = "html-tree-builder"
path = "tests/html-tree-builder.rs"
harness = false
[[test]]
name = "html-tree-sink"
path = "tests/html-tree-sink.rs"
[[test]]
name = "xml-driver"
path = "tests/xml-driver.rs"
[[test]]
name = "xml-tokenizer"
path = "tests/xml-tokenizer.rs"
harness = false
[[test]]
name = "xml-tree-builder"
path = "tests/xml-tree-builder.rs"
harness = false
[dependencies.html5ever]
version = "0.35.0"
[dependencies.markup5ever]
version = "0.35.0"
[dependencies.tendril]
version = "0.4"
[dependencies.xml5ever]
version = "0.35.0"
[dev-dependencies.env_logger]
version = "0.10"
[dev-dependencies.libtest-mimic]
version = "0.8.1"
[dev-dependencies.serde_json]
version = "1.0"
markup5ever_rcdom-0.35.0+unofficial/Cargo.toml.orig 0000644 0000000 0000000 00000001540 10461020230 0020345 0 ustar 0000000 0000000 [package]
name = "markup5ever_rcdom"
version = "0.35.0+unofficial"
description = "Basic, unsupported DOM structure for use by tests in html5ever/xml5ever"
readme = "README.md"
documentation = "https://docs.rs/markup5ever_rcdom"
categories = [ "parser-implementations", "web-programming" ]
publish = true
license.workspace = true
authors.workspace = true
repository.workspace = true
edition.workspace = true
[lib]
path = "lib.rs"
[dependencies]
html5ever = { workspace = true }
markup5ever = { workspace = true }
xml5ever = { workspace = true }
tendril = { workspace = true }
[dev-dependencies]
libtest-mimic = "0.8.1"
serde_json = "1.0"
env_logger = "0.10"
[[test]]
name = "html-tokenizer"
harness = false
[[test]]
name = "html-tree-builder"
harness = false
[[test]]
name = "xml-tree-builder"
harness = false
[[test]]
name = "xml-tokenizer"
harness = false
markup5ever_rcdom-0.35.0+unofficial/LICENSE-APACHE 0000644 0000000 0000000 00000025137 10461020230 0017412 0 ustar 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
markup5ever_rcdom-0.35.0+unofficial/LICENSE-MIT 0000644 0000000 0000000 00000002064 10461020230 0017114 0 ustar 0000000 0000000 Copyright (c) 2014 The html5ever Project Developers
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.
markup5ever_rcdom-0.35.0+unofficial/README.md 0000644 0000000 0000000 00000000703 10461020230 0016735 0 ustar 0000000 0000000 # markup5ever_rcdom
This crate is built for the express purpose of writing automated tests for the `html5ever`
and `xml5ever` crates. It is not intended to be a production-quality DOM implementation,
and has not been fuzzed or tested against arbitrary, malicious, or nontrivial inputs. No maintenance
or support for any such issues will be provided. If you use this DOM implementation in a production,
user-facing system, you do so at your own risk.
markup5ever_rcdom-0.35.0+unofficial/custom-html5lib-tokenizer-tests/regression.test 0000644 0000000 0000000 00000003125 10461020230 0026740 0 ustar 0000000 0000000 {"tests": [
{"description": "Nested HTML comment",
"input": "",
"output": [
["StartTag", "j", {"0": ""}]
],
"errors": [
{"code": "missing-attribute-value"}
]},
{"description": "Windows newline in docstring",
"input": "",
"output": [],
"errors": [
{"code": "eof-in-tag"}
]},
{"description": "Windows newline between unquoted attributes",
"input": "",
"output": [],
"errors": [
{"code": "missing-semicolon-after-character-reference"},
{"code": "eof-in-tag"}
]},
{"description": "Windows newline after bogusname",
"input": "&0\r\n",
"output": [["Character", "&0\n"]],
"errors": []},
{"description": "Bogus comment after end tag with space",
"initialStates": ["Data state", "RCDATA state", "RAWTEXT state", "Script data state"],
"lastStartTag": "style",
"input": "",
"output": [
["EndTag", "style"],
["Comment", "a"]
],
"errors": [
{"code": "incorrectly-opened-comment"}
]},
{"description": "Bogus comment after end tag with solidus",
"initialStates": ["Data state", "RCDATA state", "RAWTEXT state", "Script data state"],
"lastStartTag": "style",
"input": "",
"output": [
["EndTag", "style"],
["Comment", "a"]
],
"errors": [
{"code": "unexpected-solidus-in-tag"},
{"code": "incorrectly-opened-comment"}
]}
]}
markup5ever_rcdom-0.35.0+unofficial/data/test/ignore 0000644 0000000 0000000 00000000001 10461020230 0020543 0 ustar 0000000 0000000
markup5ever_rcdom-0.35.0+unofficial/examples/hello_xml.rs 0000644 0000000 0000000 00000002222 10461020230 0021623 0 ustar 0000000 0000000 #!/usr/bin/env run-cargo-script
//! This is a regular crate doc comment, but it also contains a partial
//! Cargo manifest. Note the use of a *fenced* code block, and the
//! `cargo` "language".
//!
//! ```cargo
//! [dependencies]
//! xml5ever = "0.2.0"
//! tendril = "0.1.3"
//! ```
extern crate markup5ever_rcdom as rcdom;
extern crate xml5ever;
use rcdom::{NodeData, RcDom};
use xml5ever::driver::parse_document;
use xml5ever::tendril::TendrilSink;
use xml5ever::tree_builder::TreeSink;
fn main() {
env_logger::init();
// To parse a string into a tree of nodes, we need to invoke
// `parse_document` and supply it with a TreeSink implementation (RcDom).
let dom: RcDom = parse_document(RcDom::default(), Default::default()).one("XML");
// Do some processing
let doc = &dom.document;
let hello_node = &doc.children.borrow()[0];
let hello_tag = dom.elem_name(hello_node).local;
let text_node = &hello_node.children.borrow()[0];
let mut xml = String::new();
if let NodeData::Text { contents } = &text_node.data {
xml.push_str(&contents.borrow());
}
println!("{hello_tag:?} {xml:?}!");
}
markup5ever_rcdom-0.35.0+unofficial/examples/html2html.rs 0000644 0000000 0000000 00000003323 10461020230 0021556 0 ustar 0000000 0000000 // Copyright 2014-2017 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Parse and re-serialize a HTML5 document.
//!
//! This is meant to produce the exact same output (ignoring stderr) as
//!
//! java -classpath htmlparser-1.4.jar nu.validator.htmlparser.tools.HTML2HTML
//!
//! where htmlparser-1.4.jar comes from http://about.validator.nu/htmlparser/
extern crate html5ever;
extern crate markup5ever_rcdom as rcdom;
use std::io::{self, Write};
use html5ever::driver::ParseOpts;
use html5ever::tendril::TendrilSink;
use html5ever::tree_builder::TreeBuilderOpts;
use html5ever::{parse_document, serialize};
use rcdom::{RcDom, SerializableHandle};
fn main() {
env_logger::init();
let opts = ParseOpts {
tree_builder: TreeBuilderOpts {
drop_doctype: true,
..Default::default()
},
..Default::default()
};
let stdin = io::stdin();
let dom = parse_document(RcDom::default(), opts)
.from_utf8()
.read_from(&mut stdin.lock())
.unwrap();
// The validator.nu HTML2HTML always prints a doctype at the very beginning.
io::stdout()
.write_all(b"\n")
.expect("writing DOCTYPE failed");
let document: SerializableHandle = dom.document.clone().into();
serialize(&mut io::stdout(), &document, Default::default()).expect("serialization failed");
}
markup5ever_rcdom-0.35.0+unofficial/examples/print-rcdom.rs 0000644 0000000 0000000 00000004311 10461020230 0022077 0 ustar 0000000 0000000 // Copyright 2014-2017 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate html5ever;
extern crate markup5ever_rcdom as rcdom;
use std::io;
use html5ever::parse_document;
use html5ever::tendril::TendrilSink;
use rcdom::{Handle, NodeData, RcDom};
// This is not proper HTML serialization, of course.
fn walk(indent: usize, handle: &Handle) {
let node = handle;
for _ in 0..indent {
print!(" ");
}
match node.data {
NodeData::Document => println!("#Document"),
NodeData::Doctype {
ref name,
ref public_id,
ref system_id,
} => println!(""),
NodeData::Text { ref contents } => {
println!("#text: {}", contents.borrow().escape_default())
},
NodeData::Comment { ref contents } => println!("", contents.escape_default()),
NodeData::Element {
ref name,
ref attrs,
..
} => {
assert!(name.ns == ns!(html));
print!("<{}", name.local);
for attr in attrs.borrow().iter() {
assert!(attr.name.ns == ns!());
print!(" {}=\"{}\"", attr.name.local, attr.value);
}
println!(">");
},
NodeData::ProcessingInstruction { .. } => unreachable!(),
}
for child in node.children.borrow().iter() {
walk(indent + 4, child);
}
}
fn main() {
let stdin = io::stdin();
let dom = parse_document(RcDom::default(), Default::default())
.from_utf8()
.read_from(&mut stdin.lock())
.unwrap();
walk(0, &dom.document);
if !dom.errors.borrow().is_empty() {
println!("\nParse errors:");
for err in dom.errors.borrow().iter() {
println!(" {err}");
}
}
}
markup5ever_rcdom-0.35.0+unofficial/examples/xml_tree_printer.rs 0000644 0000000 0000000 00000003164 10461020230 0023230 0 ustar 0000000 0000000 #!/usr/bin/env run-cargo-script
//! This is a regular crate doc comment, but it also contains a partial
//! Cargo manifest. Note the use of a *fenced* code block, and the
//! `cargo` "language".
//!
//! ```cargo
//! [dependencies]
//! xml5ever = "0.2.0"
//! tendril = "0.1.3"
//! ```
extern crate markup5ever_rcdom as rcdom;
extern crate xml5ever;
use std::io;
use rcdom::{Handle, NodeData, RcDom};
use xml5ever::driver::parse_document;
use xml5ever::tendril::TendrilSink;
fn walk(prefix: &str, handle: &Handle) {
let node = handle;
print!("{prefix}");
match node.data {
NodeData::Document => println!("#document"),
NodeData::Text { ref contents } => println!("#text {}", contents.borrow().escape_default()),
NodeData::Element { ref name, .. } => {
println!("{}", name.local);
},
_ => {},
}
let new_indent = {
let mut temp = String::new();
temp.push_str(prefix);
temp.push_str(" ");
temp
};
for child in node
.children
.borrow()
.iter()
.filter(|child| matches!(child.data, NodeData::Text { .. } | NodeData::Element { .. }))
{
walk(&new_indent, child);
}
}
fn main() {
env_logger::init();
let stdin = io::stdin();
// To parse XML into a tree form, we need a TreeSink
// luckily xml5ever comes with a static RC backed tree represetation.
let dom: RcDom = parse_document(RcDom::default(), Default::default())
.from_utf8()
.read_from(&mut stdin.lock())
.unwrap();
// Execute our visualizer on RcDom
walk("", &dom.document);
}
markup5ever_rcdom-0.35.0+unofficial/lib.rs 0000644 0000000 0000000 00000036273 10461020230 0016605 0 ustar 0000000 0000000 // Copyright 2014-2017 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! A simple reference-counted DOM.
//!
//! This is sufficient as a static parse tree, but don't build a
//! web browser using it. :)
//!
//! A DOM is a [tree structure] with ordered children that can be represented in an XML-like
//! format. For example, the following graph
//!
//! ```text
//! div
//! +- "text node"
//! +- span
//! ```
//! in HTML would be serialized as
//!
//! ```html
//!
text node
//! ```
//!
//! See the [document object model article on wikipedia][dom wiki] for more information.
//!
//! This implementation stores the information associated with each node once, and then hands out
//! refs to children. The nodes themselves are reference-counted to avoid copying - you can create
//! a new ref and then a node will outlive the document. Nodes own their children, but only have
//! weak references to their parents.
//!
//! [tree structure]: https://en.wikipedia.org/wiki/Tree_(data_structure)
//! [dom wiki]: https://en.wikipedia.org/wiki/Document_Object_Model
extern crate markup5ever;
extern crate tendril;
use std::borrow::Cow;
use std::cell::{Cell, RefCell};
use std::collections::{HashSet, VecDeque};
use std::default::Default;
use std::fmt;
use std::io;
use std::mem;
use std::rc::{Rc, Weak};
use tendril::StrTendril;
use markup5ever::interface::tree_builder;
use markup5ever::interface::tree_builder::{ElementFlags, NodeOrText, QuirksMode, TreeSink};
use markup5ever::serialize::TraversalScope;
use markup5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use markup5ever::serialize::{Serialize, Serializer};
use markup5ever::Attribute;
use markup5ever::ExpandedName;
use markup5ever::QualName;
/// The different kinds of nodes in the DOM.
#[derive(Debug)]
pub enum NodeData {
/// The `Document` itself - the root node of a HTML document.
Document,
/// A `DOCTYPE` with name, public id, and system id. See
/// [document type declaration on wikipedia][dtd wiki].
///
/// [dtd wiki]: https://en.wikipedia.org/wiki/Document_type_declaration
Doctype {
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril,
},
/// A text node.
Text { contents: RefCell },
/// A comment.
Comment { contents: StrTendril },
/// An element with attributes.
Element {
name: QualName,
attrs: RefCell>,
/// For HTML \ elements, the [template contents].
///
/// [template contents]: https://html.spec.whatwg.org/multipage/#template-contents
template_contents: RefCell
"#);
// FIXME: test serialization of qualified tag/attribute names that can't be
// parsed from HTML
test!(attr_ns_1, r#""#);
test!(attr_ns_2, r#""#);
test!(attr_ns_3, r#""#);
test!(attr_ns_4, r#""#);
test_no_parse!(malformed_tokens, r#"foo
"#);
#[test]
fn doctype() {
let dom = parse_document(RcDom::default(), ParseOpts::default()).one("");
dom.document.children.borrow_mut().truncate(1); // Remove
let mut result = vec![];
let document: SerializableHandle = dom.document.clone().into();
serialize(&mut result, &document, Default::default()).unwrap();
assert_eq!(String::from_utf8(result).unwrap(), "");
}
#[test]
fn deep_tree() {
let parser = parse_fragment(
RcDom::default(),
ParseOpts::default(),
QualName::new(None, ns!(html), local_name!("div")),
vec![],
true,
);
let src = "".repeat(60_000);
let dom = parser.one(src);
let opts = SerializeOpts::default();
let mut ret_val = Vec::new();
let document: SerializableHandle = dom.document.clone().into();
serialize(&mut ret_val, &document, opts)
.expect("Writing to a string shouldn't fail (expect on OOM)");
}
markup5ever_rcdom-0.35.0+unofficial/tests/html-tokenizer.rs 0000644 0000000 0000000 00000035010 10461020230 0022141 0 ustar 0000000 0000000 // Copyright 2014-2017 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
mod foreach_html5lib_test;
use foreach_html5lib_test::foreach_html5lib_test;
use html5ever::tendril::*;
use html5ever::tokenizer::states::{
CdataSection, Data, Plaintext, RawData, Rawtext, Rcdata, ScriptData,
};
use html5ever::tokenizer::BufferQueue;
use html5ever::tokenizer::{CharacterTokens, EOFToken, NullCharacterToken, ParseError};
use html5ever::tokenizer::{CommentToken, DoctypeToken, TagToken, Token};
use html5ever::tokenizer::{Doctype, EndTag, StartTag, Tag};
use html5ever::tokenizer::{TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts};
use html5ever::{ns, Attribute, LocalName, QualName};
use serde_json::{Map, Value};
use std::cell::RefCell;
use std::char;
use std::ffi::OsStr;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use util::runner::{run_all, Test};
mod util {
pub mod runner;
}
#[derive(Debug)]
struct TestError;
impl PartialEq for TestError {
fn eq(&self, _: &TestError) -> bool {
// TODO: actually match exact error messages
true
}
}
// some large testcases hang forever without an upper-bound of splits to generate
const MAX_SPLITS: usize = 1000;
// Return all ways of splitting the string into at most n
// possibly-empty pieces.
fn splits(s: &str, n: usize) -> Vec> {
if n == 1 {
return vec![vec![s.to_tendril()]];
}
let mut out = vec![];
for p in s.char_indices().map(|(n, _)| n).chain(Some(s.len())) {
let y = &s[p..];
for mut x in splits(&s[..p], n - 1).into_iter() {
x.push(y.to_tendril());
out.push(x);
}
}
out.extend(splits(s, n - 1));
out.truncate(MAX_SPLITS);
out
}
struct TokenLogger {
tokens: RefCell>,
errors: RefCell>,
current_str: RefCell,
exact_errors: bool,
}
impl TokenLogger {
fn new(exact_errors: bool) -> TokenLogger {
TokenLogger {
tokens: RefCell::new(vec![]),
errors: RefCell::new(vec![]),
current_str: RefCell::new(StrTendril::new()),
exact_errors,
}
}
// Push anything other than character tokens
fn push(&self, token: Token) {
self.finish_str();
self.tokens.borrow_mut().push(token);
}
fn finish_str(&self) {
if !self.current_str.borrow().is_empty() {
let s = self.current_str.take();
self.tokens.borrow_mut().push(CharacterTokens(s));
}
}
fn get_tokens(self) -> (Vec, Vec) {
self.finish_str();
(self.tokens.take(), self.errors.take())
}
}
impl TokenSink for TokenLogger {
type Handle = ();
fn process_token(&self, token: Token, _line_number: u64) -> TokenSinkResult<()> {
match token {
CharacterTokens(b) => {
self.current_str.borrow_mut().push_slice(&b);
},
NullCharacterToken => {
self.current_str.borrow_mut().push_char('\0');
},
ParseError(_) => {
if self.exact_errors {
self.errors.borrow_mut().push(TestError);
}
},
TagToken(mut t) => {
// The spec seems to indicate that one can emit
// erroneous end tags with attrs, but the test
// cases don't contain them.
match t.kind {
EndTag => {
t.self_closing = false;
t.attrs = vec![];
},
_ => t.attrs.sort_by(|a1, a2| a1.name.cmp(&a2.name)),
}
self.push(TagToken(t));
},
EOFToken => (),
_ => self.push(token),
}
TokenSinkResult::Continue
}
}
fn tokenize(input: Vec, opts: TokenizerOpts) -> (Vec, Vec) {
let sink = TokenLogger::new(opts.exact_errors);
let tok = Tokenizer::new(sink, opts);
let buffer = BufferQueue::default();
for chunk in input.into_iter() {
buffer.push_back(chunk);
let _ = tok.feed(&buffer);
}
let _ = tok.feed(&buffer);
tok.end();
tok.sink.get_tokens()
}
trait JsonExt: Sized {
fn get_str(&self) -> String;
fn get_tendril(&self) -> StrTendril;
fn get_nullable_tendril(&self) -> Option;
fn get_bool(&self) -> bool;
fn get_obj(&self) -> ⤅
fn get_list(&self) -> &Vec;
fn find(&self, key: &str) -> &Self;
}
impl JsonExt for Value {
fn get_str(&self) -> String {
match *self {
Value::String(ref s) => s.to_string(),
_ => panic!("Value::get_str: not a String"),
}
}
fn get_tendril(&self) -> StrTendril {
match *self {
Value::String(ref s) => s.to_tendril(),
_ => panic!("Value::get_tendril: not a String"),
}
}
fn get_nullable_tendril(&self) -> Option {
match *self {
Value::Null => None,
Value::String(ref s) => Some(s.to_tendril()),
_ => panic!("Value::get_nullable_tendril: not a String"),
}
}
fn get_bool(&self) -> bool {
match *self {
Value::Bool(b) => b,
_ => panic!("Value::get_bool: not a Bool"),
}
}
fn get_obj(&self) -> &Map {
match self {
Value::Object(m) => m,
_ => panic!("Value::get_obj: not an Object"),
}
}
fn get_list(&self) -> &Vec {
match self {
Value::Array(m) => m,
_ => panic!("Value::get_list: not an Array"),
}
}
fn find(&self, key: &str) -> &Value {
self.get_obj().get(key).unwrap()
}
}
// Parse a JSON object (other than "ParseError") to a token.
fn json_to_token(js: &Value) -> Token {
let parts = js.get_list();
// Collect refs here so we don't have to use "ref" in all the patterns below.
let args: Vec<&Value> = parts[1..].iter().collect();
match &*parts[0].get_str() {
"DOCTYPE" => DoctypeToken(Doctype {
name: args[0].get_nullable_tendril(),
public_id: args[1].get_nullable_tendril(),
system_id: args[2].get_nullable_tendril(),
force_quirks: !args[3].get_bool(),
}),
"StartTag" => TagToken(Tag {
kind: StartTag,
name: LocalName::from(&*args[0].get_str()),
attrs: args[1]
.get_obj()
.iter()
.map(|(k, v)| Attribute {
name: QualName::new(None, ns!(), LocalName::from(&**k)),
value: v.get_tendril(),
})
.collect(),
self_closing: match args.get(2) {
Some(b) => b.get_bool(),
None => false,
},
}),
"EndTag" => TagToken(Tag {
kind: EndTag,
name: LocalName::from(&*args[0].get_str()),
attrs: vec![],
self_closing: false,
}),
"Comment" => CommentToken(args[0].get_tendril()),
"Character" => CharacterTokens(args[0].get_tendril()),
// We don't need to produce NullCharacterToken because
// the TokenLogger will convert them to CharacterTokens.
_ => panic!("don't understand token {parts:?}"),
}
}
// Parse the "output" field of the test case into a vector of tokens.
fn json_to_tokens(
js_tokens: &Value,
js_errors: &[Value],
exact_errors: bool,
) -> (Vec, Vec) {
// Use a TokenLogger so that we combine character tokens separated
// by an ignored error.
let sink = TokenLogger::new(exact_errors);
for tok in js_tokens.get_list().iter() {
assert_eq!(
sink.process_token(json_to_token(tok), 0),
TokenSinkResult::Continue
);
}
for err in js_errors {
assert_eq!(
sink.process_token(ParseError(err.find("code").get_str().into()), 0),
TokenSinkResult::Continue
);
}
sink.get_tokens()
}
// Undo the escaping in "doubleEscaped" tests.
fn unescape(s: &str) -> Option {
let mut out = String::with_capacity(s.len());
let mut it = s.chars().peekable();
loop {
match it.next() {
None => return Some(out),
Some('\\') => {
if it.peek() != Some(&'u') {
panic!("can't understand escape");
}
let _ = it.next();
let hex: String = it.by_ref().take(4).collect();
match u32::from_str_radix(&hex, 16).ok().and_then(char::from_u32) {
// Some of the tests use lone surrogates, but we have no
// way to represent them in the UTF-8 input to our parser.
// Since these can only come from script, we will catch
// them there.
None => return None,
Some(c) => out.push(c),
}
},
Some(c) => out.push(c),
}
}
}
fn unescape_json(js: &Value) -> Value {
match js {
// unwrap is OK here because the spec'd *output* of the tokenizer never
// contains a lone surrogate.
Value::String(s) => Value::String(unescape(s).unwrap()),
Value::Array(xs) => Value::Array(xs.iter().map(unescape_json).collect()),
Value::Object(obj) => {
let mut new_obj = Map::new();
for (k, v) in obj.iter() {
new_obj.insert(k.clone(), unescape_json(v));
}
Value::Object(new_obj)
},
_ => js.clone(),
}
}
fn mk_test(
desc: String,
input: String,
expect: Value,
expect_errors: Vec,
opts: TokenizerOpts,
) -> Test {
Test {
name: desc,
skip: false,
test: Box::new(move || {
// Split up the input at different points to test incremental tokenization.
let insplits = splits(&input, 3);
for input in insplits.into_iter() {
// Clone 'input' so we have it for the failure message.
// Also clone opts. If we don't, we get the wrong
// result but the compiler doesn't catch it!
// Possibly mozilla/rust#12223.
let output = tokenize(input.clone(), opts.clone());
let expect_toks = json_to_tokens(&expect, &expect_errors, opts.exact_errors);
if output != expect_toks {
panic!("\ninput: {input:?}\ngot: {output:?}\nexpected: {expect_toks:?}");
}
}
}),
}
}
fn mk_tests(tests: &mut Vec, filename: &str, js: &Value) {
let obj = js.get_obj();
let mut input = js.find("input").get_str();
let mut expect = js.find("output").clone();
let expect_errors = js
.get("errors")
.map(JsonExt::get_list)
.map(Vec::as_slice)
.unwrap_or_default();
let desc = format!("tok: {}: {}", filename, js.find("description").get_str());
// "Double-escaped" tests require additional processing of
// the input and output.
if obj
.get(&"doubleEscaped".to_string())
.is_some_and(|j| j.get_bool())
{
match unescape(&input) {
None => return,
Some(i) => input = i,
}
expect = unescape_json(&expect);
}
// Some tests have a last start tag name.
let start_tag = obj.get(&"lastStartTag".to_string()).map(|s| s.get_str());
// Some tests want to start in a state other than Data.
let state_overrides = match obj.get(&"initialStates".to_string()) {
Some(Value::Array(xs)) => xs
.iter()
.map(|s| {
Some(match &s.get_str()[..] {
"PLAINTEXT state" => Plaintext,
"RAWTEXT state" => RawData(Rawtext),
"RCDATA state" => RawData(Rcdata),
"Script data state" => RawData(ScriptData),
"CDATA section state" => CdataSection,
"Data state" => Data,
s => panic!("don't know state {s}"),
})
})
.collect(),
None => vec![None],
_ => panic!("don't understand initialStates value"),
};
// Build the tests.
for state in state_overrides.into_iter() {
for &exact_errors in [false, true].iter() {
let mut newdesc = desc.clone();
if let Some(s) = state {
newdesc = format!("{newdesc} (in state {s:?})")
};
if exact_errors {
newdesc = format!("{newdesc} (exact errors)");
}
tests.push(mk_test(
newdesc,
input.clone(),
expect.clone(),
expect_errors.to_owned(),
TokenizerOpts {
exact_errors,
initial_state: state,
last_start_tag_name: start_tag.clone(),
// Not discarding a BOM is what the test suite expects; see
// https://github.com/html5lib/html5lib-tests/issues/2
discard_bom: false,
..Default::default()
},
));
}
}
}
fn tests(src_dir: &Path) -> Vec {
let mut tests = vec![];
let mut add_test = |path: &Path, mut file: File| {
let mut s = String::new();
file.read_to_string(&mut s).expect("file reading error");
let js: Value = serde_json::from_str(&s).expect("json parse error");
if let Some(Value::Array(lst)) = js.get_obj().get("tests") {
for test in lst.iter() {
mk_tests(
&mut tests,
path.file_name().unwrap().to_str().unwrap(),
test,
)
}
}
};
foreach_html5lib_test(
src_dir,
"html5lib-tests/tokenizer",
OsStr::new("test"),
&mut add_test,
);
foreach_html5lib_test(
src_dir,
"custom-html5lib-tokenizer-tests",
OsStr::new("test"),
&mut add_test,
);
tests
}
fn main() {
run_all(tests(Path::new("./")));
}
markup5ever_rcdom-0.35.0+unofficial/tests/html-tree-builder.rs 0000644 0000000 0000000 00000021726 10461020230 0022523 0 ustar 0000000 0000000 // Copyright 2014-2017 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate markup5ever_rcdom as rcdom;
#[macro_use]
extern crate html5ever;
mod foreach_html5lib_test;
use foreach_html5lib_test::foreach_html5lib_test;
use std::collections::{HashMap, HashSet};
use std::ffi::OsStr;
use std::io::BufRead;
use std::path::Path;
use std::{fs, io, iter, mem};
use html5ever::tendril::{StrTendril, TendrilSink};
use html5ever::{parse_document, parse_fragment, ParseOpts};
use html5ever::{LocalName, QualName};
use rcdom::{Handle, NodeData, RcDom};
use util::runner::{run_all, Test};
mod util {
pub mod runner;
}
fn parse_tests>(mut lines: It) -> Vec> {
let mut tests = vec![];
let mut test = HashMap::new();
let mut key: Option = None;
let mut val = String::new();
macro_rules! finish_val ( () => (
match key.take() {
None => (),
Some(key) => {
assert!(test.insert(key, mem::take(&mut val)).is_none());
}
}
));
macro_rules! finish_test ( () => (
if !test.is_empty() {
tests.push(mem::take(&mut test));
}
));
loop {
match lines.next() {
None => break,
Some(line) => {
if let Some(rest) = line.strip_prefix('#') {
finish_val!();
if line == "#data" {
finish_test!();
}
key = Some(rest.to_owned());
} else {
val.push_str(&line);
val.push('\n');
}
},
}
}
finish_val!();
finish_test!();
tests
}
fn serialize(buf: &mut String, indent: usize, handle: Handle) {
buf.push('|');
buf.extend(iter::repeat_n(" ", indent));
let node = handle;
match node.data {
NodeData::Document => panic!("should not reach Document"),
NodeData::Doctype {
ref name,
ref public_id,
ref system_id,
} => {
buf.push_str("\n");
},
NodeData::Text { ref contents } => {
buf.push('"');
buf.push_str(&contents.borrow());
buf.push_str("\"\n");
},
NodeData::Comment { ref contents } => {
buf.push_str("\n");
},
NodeData::Element {
ref name,
ref attrs,
..
} => {
buf.push('<');
match name.ns {
ns!(svg) => buf.push_str("svg "),
ns!(mathml) => buf.push_str("math "),
_ => (),
}
buf.push_str(&name.local);
buf.push_str(">\n");
let mut attrs = attrs.borrow().clone();
attrs.sort_by(|x, y| x.name.local.cmp(&y.name.local));
// FIXME: sort by UTF-16 code unit
for attr in attrs.into_iter() {
buf.push('|');
buf.extend(iter::repeat_n(" ", indent + 2));
match attr.name.ns {
ns!(xlink) => buf.push_str("xlink "),
ns!(xml) => buf.push_str("xml "),
ns!(xmlns) => buf.push_str("xmlns "),
_ => (),
}
buf.push_str(&format!("{}=\"{}\"\n", attr.name.local, attr.value));
}
},
NodeData::ProcessingInstruction { .. } => unreachable!(),
}
for child in node.children.borrow().iter() {
serialize(buf, indent + 2, child.clone());
}
if let NodeData::Element {
ref template_contents,
..
} = node.data
{
if let Some(ref content) = &*template_contents.borrow() {
buf.push('|');
buf.extend(iter::repeat_n(" ", indent + 2));
buf.push_str("content\n");
for child in content.children.borrow().iter() {
serialize(buf, indent + 4, child.clone());
}
}
}
}
fn make_test(
tests: &mut Vec,
ignores: &HashSet,
filename: &str,
idx: usize,
fields: HashMap,
) {
let scripting_flags = &[false, true];
let scripting_flags = if fields.contains_key("script-off") {
&scripting_flags[0..1]
} else if fields.contains_key("script-on") {
&scripting_flags[1..2]
} else {
&scripting_flags[0..2]
};
let name = format!("tb: {filename}-{idx}");
for scripting_enabled in scripting_flags {
let test = make_test_desc_with_scripting_flag(ignores, &name, &fields, *scripting_enabled);
tests.push(test);
}
}
fn make_test_desc_with_scripting_flag(
ignores: &HashSet,
name: &str,
fields: &HashMap,
scripting_enabled: bool,
) -> Test {
let get_field = |key| {
let field = fields.get(key).expect("missing field");
field.trim_end_matches('\n').to_string()
};
let mut data = fields.get("data").expect("missing data").to_string();
data.pop();
let expected = get_field("document");
let context = fields
.get("document-fragment")
.map(|field| context_name(field.trim_end_matches('\n')));
let skip = ignores.contains(name);
let mut name = name.to_owned();
if scripting_enabled {
name.push_str(" (scripting enabled)");
} else {
name.push_str(" (scripting disabled)");
};
Test {
name,
skip,
test: Box::new(move || {
// Do this here because Tendril isn't Send.
let data = StrTendril::from_slice(&data);
let mut opts: ParseOpts = Default::default();
opts.tree_builder.scripting_enabled = scripting_enabled;
let mut result = String::new();
match context {
None => {
let dom = parse_document(RcDom::default(), opts).one(data.clone());
for child in dom.document.children.borrow().iter() {
serialize(&mut result, 1, child.clone());
}
},
Some(ref context) => {
let dom = parse_fragment(RcDom::default(), opts, context.clone(), vec![], true)
.one(data.clone());
// fragment case: serialize children of the html element
// rather than children of the document
let doc = &dom.document;
let root = &doc.children.borrow()[0];
for child in root.children.borrow().iter() {
serialize(&mut result, 1, child.clone());
}
},
};
let len = result.len();
result.truncate(len - 1); // drop the trailing newline
if result != expected {
panic!("\ninput: {data}\ngot:\n{result}\nexpected:\n{expected}\n");
}
}),
}
}
fn context_name(context: &str) -> QualName {
if let Some(cx) = context.strip_prefix("svg ") {
QualName::new(None, ns!(svg), LocalName::from(cx))
} else if let Some(cx) = context.strip_prefix("math ") {
QualName::new(None, ns!(mathml), LocalName::from(cx))
} else {
QualName::new(None, ns!(html), LocalName::from(context))
}
}
fn tests(src_dir: &Path, ignores: &HashSet) -> Vec {
let mut tests = vec![];
foreach_html5lib_test(
src_dir,
"html5lib-tests/tree-construction",
OsStr::new("dat"),
|path, file| {
let buf = io::BufReader::new(file);
let lines = buf.lines().map(|res| res.expect("couldn't read"));
let data = parse_tests(lines);
for (i, test) in data.into_iter().enumerate() {
make_test(
&mut tests,
ignores,
path.file_name().unwrap().to_str().unwrap(),
i,
test,
);
}
},
);
tests
}
fn main() {
let src_dir = Path::new("./");
let mut ignores = HashSet::new();
{
let f = fs::File::open(src_dir.join("data/test/ignore")).unwrap();
let r = io::BufReader::new(f);
for ln in r.lines() {
ignores.insert(ln.unwrap().trim_end().to_string());
}
}
run_all(tests(src_dir, &ignores));
}
markup5ever_rcdom-0.35.0+unofficial/tests/html-tree-sink.rs 0000644 0000000 0000000 00000010070 10461020230 0022027 0 ustar 0000000 0000000 use html5ever::driver;
use html5ever::tendril::stream::TendrilSink;
use html5ever::tendril::StrTendril;
use html5ever::ExpandedName;
use html5ever::QualName;
use markup5ever::interface::{ElementFlags, NodeOrText, QuirksMode, TreeSink};
use markup5ever::{local_name, ns, Attribute};
use markup5ever_rcdom::{Handle, RcDom};
use std::borrow::Cow;
use std::cell::{Cell, RefCell};
pub struct LineCountingDOM {
pub line_vec: RefCell>,
pub current_line: Cell,
pub rcdom: RcDom,
}
impl TreeSink for LineCountingDOM {
type Output = Self;
type ElemName<'a> = ExpandedName<'a>;
fn finish(self) -> Self {
self
}
type Handle = Handle;
fn parse_error(&self, msg: Cow<'static, str>) {
self.rcdom.parse_error(msg);
}
fn get_document(&self) -> Handle {
self.rcdom.get_document()
}
fn get_template_contents(&self, target: &Handle) -> Handle {
self.rcdom.get_template_contents(target)
}
fn set_quirks_mode(&self, mode: QuirksMode) {
self.rcdom.set_quirks_mode(mode)
}
fn same_node(&self, x: &Handle, y: &Handle) -> bool {
self.rcdom.same_node(x, y)
}
fn elem_name<'a>(&'a self, target: &'a Handle) -> ExpandedName<'a> {
self.rcdom.elem_name(target)
}
fn create_element(&self, name: QualName, attrs: Vec, flags: ElementFlags) -> Handle {
self.line_vec
.borrow_mut()
.push((name.clone(), self.current_line.get()));
self.rcdom.create_element(name, attrs, flags)
}
fn create_comment(&self, text: StrTendril) -> Handle {
self.rcdom.create_comment(text)
}
fn create_pi(&self, target: StrTendril, content: StrTendril) -> Handle {
self.rcdom.create_pi(target, content)
}
fn append(&self, parent: &Handle, child: NodeOrText) {
self.rcdom.append(parent, child)
}
fn append_before_sibling(&self, sibling: &Handle, child: NodeOrText) {
self.rcdom.append_before_sibling(sibling, child)
}
fn append_based_on_parent_node(
&self,
element: &Handle,
prev_element: &Handle,
child: NodeOrText,
) {
self.rcdom
.append_based_on_parent_node(element, prev_element, child)
}
fn append_doctype_to_document(
&self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril,
) {
self.rcdom
.append_doctype_to_document(name, public_id, system_id);
}
fn add_attrs_if_missing(&self, target: &Handle, attrs: Vec) {
self.rcdom.add_attrs_if_missing(target, attrs);
}
fn remove_from_parent(&self, target: &Handle) {
self.rcdom.remove_from_parent(target);
}
fn reparent_children(&self, node: &Handle, new_parent: &Handle) {
self.rcdom.reparent_children(node, new_parent);
}
fn mark_script_already_started(&self, target: &Handle) {
self.rcdom.mark_script_already_started(target);
}
fn set_current_line(&self, line_number: u64) {
self.current_line.set(line_number);
}
}
#[test]
fn check_four_lines() {
// Input
let sink = LineCountingDOM {
line_vec: RefCell::new(vec![]),
current_line: Cell::new(1),
rcdom: RcDom::default(),
};
let mut result_tok = driver::parse_document(sink, Default::default());
result_tok.process(StrTendril::from("\n"));
result_tok.process(StrTendril::from("\n"));
result_tok.process(StrTendril::from("\n"));
result_tok.process(StrTendril::from(""));
// Actual Output
let actual = result_tok.finish();
// Expected Output
let expected = vec![
(QualName::new(None, ns!(html), local_name!("html")), 1),
(QualName::new(None, ns!(html), local_name!("head")), 1),
(QualName::new(None, ns!(html), local_name!("body")), 1),
(QualName::new(None, ns!(html), local_name!("a")), 1),
(QualName::new(None, ns!(html), local_name!("b")), 3),
];
// Assertion
assert_eq!(*actual.line_vec.borrow(), expected);
}
markup5ever_rcdom-0.35.0+unofficial/tests/util/find_tests.rs 0000644 0000000 0000000 00000002040 10461020230 0022301 0 ustar 0000000 0000000 // Copyright 2014-2017 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
pub fn foreach_xml5lib_test(
src_dir: &Path,
subdir: &'static str,
ext: &'static OsStr,
mut mk: Mk,
) where
Mk: FnMut(&Path, fs::File),
{
let mut test_dir_path = src_dir.to_path_buf();
test_dir_path.push("xml5lib-tests");
test_dir_path.push(subdir);
let test_files = fs::read_dir(&test_dir_path).unwrap();
for entry in test_files {
let path = entry.unwrap().path();
if path.extension() == Some(ext) {
let file = fs::File::open(&path).unwrap();
mk(&path, file);
}
}
}
markup5ever_rcdom-0.35.0+unofficial/tests/util/runner.rs 0000644 0000000 0000000 00000002623 10461020230 0021457 0 ustar 0000000 0000000 // Copyright 2024 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use libtest_mimic::{Arguments, Trial};
/// Simple container for storing tests for later execution
pub struct Test {
pub name: String,
pub skip: bool,
pub test: Box,
}
impl Test {
/// Invoke the stored test function
///
/// A status message is printed if the wrapped closure completes
/// or is marked as skipped. The test should panic to report
/// failure.
pub fn run(&self) {
print!("test {} ...", self.name);
if self.skip {
println!(" SKIPPED");
} else {
(self.test)();
println!(" ok");
}
}
}
pub fn run_all(tests: Vec) {
let mut harness_tests = Vec::new();
for test in tests {
let harness_test = Trial::test(test.name.clone(), move || {
test.run();
Ok(())
});
harness_tests.push(harness_test);
}
let args = Arguments::from_args();
libtest_mimic::run(&args, harness_tests).exit();
}
markup5ever_rcdom-0.35.0+unofficial/tests/xml-driver.rs 0000644 0000000 0000000 00000006542 10461020230 0021266 0 ustar 0000000 0000000 use markup5ever_rcdom::{RcDom, SerializableHandle};
use xml5ever::driver;
use xml5ever::serialize;
use xml5ever::tendril::TendrilSink;
#[test]
fn el_ns_serialize() {
assert_eq_serialization(
"Test",
driver::parse_document(RcDom::default(), Default::default())
.from_utf8()
.one("Test".as_bytes()),
);
}
#[test]
fn nested_ns_serialize() {
assert_eq_serialization("",
driver::parse_document(RcDom::default(), Default::default())
.from_utf8()
.one("".as_bytes()));
}
#[test]
fn def_ns_serialize() {
assert_eq_serialization(
"