aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFinn Behrens <me@kloenk.de>2020-11-08 22:24:28 +0100
committerFinn Behrens <me@kloenk.de>2020-11-08 22:24:28 +0100
commit4295a43c39b7d658cccd9d45de2f556fd0bc7ea3 (patch)
tree67989929a5226a9543743794c9cb148d2f5ff1b7
parent05f327773ead69c59c9fc10e152e9cdf552dc8d1 (diff)
downloadbackend-4295a43c39b7d658cccd9d45de2f556fd0bc7ea3.tar.gz
backend-4295a43c39b7d658cccd9d45de2f556fd0bc7ea3.tar.xz
backend-4295a43c39b7d658cccd9d45de2f556fd0bc7ea3.zip
move rcdom to markup5ever_rcdom
-rw-r--r--Cargo.lock326
-rw-r--r--Cargo.toml3
-rw-r--r--src/dsb/html.rs56
-rw-r--r--src/dsb/mod.rs10
-rw-r--r--src/types.rs6
5 files changed, 195 insertions, 206 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5a986eb..fb8f6c0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,12 +2,6 @@
# It is not intended for manual editing.
[[package]]
name = "autocfg"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
-
-[[package]]
-name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
@@ -19,16 +13,11 @@ dependencies = [
"chrono",
"custom_error",
"html5ever",
- "log 0.4.11",
+ "log",
+ "markup5ever_rcdom",
]
[[package]]
-name = "bitflags"
-version = "1.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
-
-[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -48,36 +37,12 @@ dependencies = [
]
[[package]]
-name = "cloudabi"
-version = "0.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-dependencies = [
- "bitflags",
-]
-
-[[package]]
name = "custom_error"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51ac5e99a7fea3ee8a03fa4721a47e2efd3fbb38358fc61192a54d4c6f866c12"
[[package]]
-name = "debug_unreachable"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3"
-dependencies = [
- "unreachable",
-]
-
-[[package]]
-name = "fuchsia-cprng"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
-
-[[package]]
name = "futf"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -88,23 +53,41 @@ dependencies = [
]
[[package]]
+name = "getrandom"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi 0.9.0+wasi-snapshot-preview1",
+]
+
+[[package]]
name = "html5ever"
-version = "0.20.0"
+version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5bfb46978eb757a603b7dfe2dafb1c62cb4dee3428d8ac1de734d83d6b022d06"
+checksum = "aafcf38a1a36118242d29b92e1b08ef84e67e4a5ed06e0a80be20e6a32bfed6b"
dependencies = [
- "log 0.3.9",
+ "log",
"mac",
"markup5ever",
- "quote 0.3.15",
+ "proc-macro2",
+ "quote",
"syn",
]
[[package]]
+name = "itoa"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
+
+[[package]]
name = "lazy_static"
-version = "0.2.11"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
@@ -114,15 +97,6 @@ checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
[[package]]
name = "log"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
-dependencies = [
- "log 0.4.11",
-]
-
-[[package]]
-name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
@@ -138,19 +112,34 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "markup5ever"
-version = "0.5.0"
+version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "047150a0e03b57e638fc45af33a0b63a0362305d5b9f92ecef81df472a4cceb0"
+checksum = "aae38d669396ca9b707bfc3db254bc382ddb94f57cc5c235f34623a669a01dab"
dependencies = [
+ "log",
"phf",
"phf_codegen",
- "rustc-serialize",
+ "serde",
+ "serde_derive",
+ "serde_json",
"string_cache",
"string_cache_codegen",
"tendril",
]
[[package]]
+name = "markup5ever_rcdom"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f015da43bcd8d4f144559a3423f4591d69b8ce0652c905374da7205df336ae2b"
+dependencies = [
+ "html5ever",
+ "markup5ever",
+ "tendril",
+ "xml5ever",
+]
+
+[[package]]
name = "new_debug_unreachable"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -162,7 +151,7 @@ version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
"num-traits",
]
@@ -172,23 +161,23 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
]
[[package]]
name = "phf"
-version = "0.7.24"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18"
+checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
dependencies = [
"phf_shared",
]
[[package]]
name = "phf_codegen"
-version = "0.7.24"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e"
+checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815"
dependencies = [
"phf_generator",
"phf_shared",
@@ -196,9 +185,9 @@ dependencies = [
[[package]]
name = "phf_generator"
-version = "0.7.24"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662"
+checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526"
dependencies = [
"phf_shared",
"rand",
@@ -206,14 +195,20 @@ dependencies = [
[[package]]
name = "phf_shared"
-version = "0.7.24"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
+checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7"
dependencies = [
"siphasher",
]
[[package]]
+name = "ppv-lite86"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
+
+[[package]]
name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -225,17 +220,11 @@ version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
- "unicode-xid 0.2.1",
+ "unicode-xid",
]
[[package]]
name = "quote"
-version = "0.3.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
-
-[[package]]
-name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
@@ -245,189 +234,129 @@ dependencies = [
[[package]]
name = "rand"
-version = "0.6.5"
+version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
+checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
- "autocfg 0.1.7",
+ "getrandom",
"libc",
"rand_chacha",
- "rand_core 0.4.2",
+ "rand_core",
"rand_hc",
- "rand_isaac",
- "rand_jitter",
- "rand_os",
"rand_pcg",
- "rand_xorshift",
- "winapi",
]
[[package]]
name = "rand_chacha"
-version = "0.1.1"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
+checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.3.1",
+ "ppv-lite86",
+ "rand_core",
]
[[package]]
name = "rand_core"
-version = "0.3.1"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
- "rand_core 0.4.2",
+ "getrandom",
]
[[package]]
-name = "rand_core"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
-
-[[package]]
name = "rand_hc"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_isaac"
-version = "0.1.1"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
+checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
- "rand_core 0.3.1",
+ "rand_core",
]
[[package]]
-name = "rand_jitter"
-version = "0.1.4"
+name = "rand_pcg"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
+checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
dependencies = [
- "libc",
- "rand_core 0.4.2",
- "winapi",
+ "rand_core",
]
[[package]]
-name = "rand_os"
-version = "0.1.3"
+name = "ryu"
+version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
-dependencies = [
- "cloudabi",
- "fuchsia-cprng",
- "libc",
- "rand_core 0.4.2",
- "rdrand",
- "winapi",
-]
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
-name = "rand_pcg"
-version = "0.1.2"
+name = "serde"
+version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.4.2",
-]
+checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
[[package]]
-name = "rand_xorshift"
-version = "0.1.1"
+name = "serde_derive"
+version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
+checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
dependencies = [
- "rand_core 0.3.1",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
-name = "rdrand"
-version = "0.4.0"
+name = "serde_json"
+version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
+checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
dependencies = [
- "rand_core 0.3.1",
+ "itoa",
+ "ryu",
+ "serde",
]
[[package]]
-name = "rustc-serialize"
-version = "0.3.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
-
-[[package]]
-name = "serde"
-version = "1.0.117"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
-
-[[package]]
name = "siphasher"
-version = "0.2.3"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
+checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7"
[[package]]
name = "string_cache"
-version = "0.6.2"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "413fc7852aeeb5472f1986ef755f561ddf0c789d3d796e65f0b6fe293ecd4ef8"
+checksum = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a"
dependencies = [
- "debug_unreachable",
"lazy_static",
+ "new_debug_unreachable",
"phf_shared",
"precomputed-hash",
"serde",
- "string_cache_codegen",
- "string_cache_shared",
]
[[package]]
name = "string_cache_codegen"
-version = "0.4.4"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6"
+checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97"
dependencies = [
"phf_generator",
"phf_shared",
"proc-macro2",
- "quote 1.0.7",
- "string_cache_shared",
+ "quote",
]
[[package]]
-name = "string_cache_shared"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
-
-[[package]]
name = "syn"
-version = "0.11.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
-dependencies = [
- "quote 0.3.15",
- "synom",
- "unicode-xid 0.0.4",
-]
-
-[[package]]
-name = "synom"
-version = "0.11.3"
+version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
+checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
dependencies = [
- "unicode-xid 0.0.4",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
]
[[package]]
@@ -448,42 +377,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
- "wasi",
+ "wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
]
[[package]]
name = "unicode-xid"
-version = "0.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
-
-[[package]]
-name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
-name = "unreachable"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
-dependencies = [
- "void",
-]
-
-[[package]]
name = "utf-8"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
[[package]]
-name = "void"
-version = "1.0.2"
+name = "wasi"
+version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
@@ -512,3 +426,15 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "xml5ever"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b1b52e6e8614d4a58b8e70cf51ec0cc21b256ad8206708bcff8139b5bbd6a59"
+dependencies = [
+ "log",
+ "mac",
+ "markup5ever",
+ "time",
+]
diff --git a/Cargo.toml b/Cargo.toml
index 2e141a6..d2da93e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,5 @@ default = []
chrono = { version = "0.4" }
custom_error = "1.8"
log = "0.4"
-html5ever = "0.20"
+html5ever = "0.25"
+markup5ever_rcdom = "0.1"
diff --git a/src/dsb/html.rs b/src/dsb/html.rs
index e69de29..51e8580 100644
--- a/src/dsb/html.rs
+++ b/src/dsb/html.rs
@@ -0,0 +1,56 @@
+use crate::types::*;
+use crate::Error;
+use super::DSB;
+
+//use html5ever::rcdom::{Handle, Node, NodeData};
+use markup5ever_rcdom::{Handle, Node, NodeData};
+use html5ever::tendril::Tendril;
+
+pub(crate) fn parse(handle: &Handle) -> Result<Vec<DSB>, Error> {
+ let mut dsb_ret = Vec::new();
+ let node: &Node = handle;
+ let nodeVec = node.children.borrow();
+ let node: &Node = &nodeVec[0];
+
+ for v in node.children.borrow().iter() {
+ let v: &Node = v;
+ if let NodeData::Element { ref name, .. } = v.data {
+ let name: &html5ever::QualName = name;
+ if name.local.to_string() == "body" {
+ let mut found_head = false;
+ for w in v.children.borrow().iter() {
+ if let NodeData::Element { ref name, ref attrs, .. } = w.data {
+ let name: &html5ever::QualName = name;
+ let attrs = &attrs.borrow();
+ println!("name: {}", name.local.to_string());
+ if name.local.to_string() == "table" {
+ for attrs in attrs.iter() {
+ if attrs.name.local.to_string() == "class" && attrs.value.to_string() == "mon_head" {
+ dsb_ret.push(new_mon_head(w)?);
+ found_head = true;
+ }
+ }
+ } else if name.local.to_string() == "center" && found_head {
+ if let Some(mut dsb) = dsb_ret.last_mut() {
+ parse_center(w, &mut dsb)?;
+ } else {
+ panic!("should get mutable");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ Ok(dsb_ret)
+}
+
+fn new_mon_head(handle: &Handle) -> Result<DSB, Error> {
+
+ todo!()
+}
+
+fn parse_center(handle: &Handle, dsb: &mut DSB) -> Result<(), Error> {
+ todo!()
+}
diff --git a/src/dsb/mod.rs b/src/dsb/mod.rs
index 7a32c1f..846b017 100644
--- a/src/dsb/mod.rs
+++ b/src/dsb/mod.rs
@@ -2,7 +2,8 @@ use crate::types::*;
use crate::Error;
use html5ever::parse_document;
-use html5ever::rcdom::RcDom;
+//use html5ever::rcdom::RcDom;
+use markup5ever_rcdom::RcDom;
use html5ever::tendril::TendrilSink;
mod html;
@@ -10,6 +11,7 @@ mod html;
#[cfg(feature = "scraper")]
use hyper::Client;
+#[derive(Debug, PartialEq, Eq, Clone)]
pub struct DSB {
pub school: String,
pub year: String,
@@ -33,7 +35,7 @@ impl DSB {
.read_from(&mut html.as_bytes())?;
- todo!()
+ html::parse(&dom.document)
}
}
@@ -75,5 +77,9 @@ mod test {
fn read_dsb() {
let html = std::fs::read_to_string("./src/dsb/mod.rs").unwrap();
let dsb = DSB::parse(&html).unwrap();
+
+ assert_eq!(dsb.len(), 3);
+
+ println!("{:?}", dsb);
}
}
diff --git a/src/types.rs b/src/types.rs
index d0f17fa..6d50af1 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -4,7 +4,7 @@ use std::fmt;
use crate::Error;
#[repr(u8)]
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Week {
A,
B,
@@ -36,7 +36,7 @@ impl TryFrom<&str> for Week {
}
}
-#[derive(Clone)]
+#[derive(Clone, PartialEq, Eq)]
pub struct Class {
pub name: String,
}
@@ -242,7 +242,7 @@ pub struct Teacher {
pub name: String,
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DsbEntry {
/// Class this one affects
pub name: String, // TODO: change to enum type