diff --git a/Cargo.lock b/Cargo.lock index 10fae527f7..c1e3e0c283 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,18 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" @@ -185,15 +194,15 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.10" +version = "3.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375" +checksum = "85a35a599b11c089a7f49105658d089b8f2cf0882993c17daf6de15285c2c35d" dependencies = [ "atty", "bitflags", + "clap_lex", "indexmap", "lazy_static", - "os_str_bytes", "strsim", "termcolor", "textwrap", @@ -208,6 +217,30 @@ dependencies = [ "clap", ] +[[package]] +name = "clap_lex" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "cpufeatures" version = "0.1.5" @@ -217,14 +250,54 @@ dependencies = [ "libc", ] +[[package]] +name = "cssparser" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31542adad356e4fd6e9df55221485a22eb69c470141e110e7dbb4a8052e45fa6" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "matches", + "phf 0.10.1", + "proc-macro2 1.0.28", + "quote 1.0.9", + "smallvec", + "syn 1.0.75", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e" +dependencies = [ + "quote 1.0.9", + "syn 1.0.75", +] + [[package]] name = "ctor" version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d" dependencies = [ - "quote", - "syn", + "quote 1.0.9", + "syn 1.0.75", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2 1.0.28", + "quote 1.0.9", + "rustc_version", + "syn 1.0.75", ] [[package]] @@ -263,6 +336,21 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + +[[package]] +name = "dtoa-short" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde03329ae10e79ede66c9ce4dc930aa8599043b0743008548680f25b91502d6" +dependencies = [ + "dtoa", +] + [[package]] name = "either" version = "1.6.1" @@ -356,6 +444,12 @@ dependencies = [ "libc", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -404,11 +498,11 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" dependencies = [ - "autocfg", + "autocfg 1.1.0", "proc-macro-hack", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -429,7 +523,7 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" dependencies = [ - "autocfg", + "autocfg 1.1.0", "futures-core", "futures-macro", "futures-sink", @@ -441,6 +535,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.12.4" @@ -525,7 +628,7 @@ dependencies = [ "log", "pest", "pest_derive", - "quick-error", + "quick-error 2.0.1", "serde", "serde_json", ] @@ -579,9 +682,9 @@ dependencies = [ "log", "mac", "markup5ever", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -665,7 +768,7 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ - "autocfg", + "autocfg 1.1.0", "hashbrown", ] @@ -735,6 +838,44 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "lewp-css" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39d5f56e217205b30a01e1ec42c608f8b14aade46c1355c7e031ac8c161dde14" +dependencies = [ + "bitflags", + "cssparser", + "either", + "lewp-selectors", + "ordermap", + "phf 0.7.24", + "phf_codegen 0.7.24", + "phf_macros 0.7.24", + "precomputed-hash", + "quick-error 1.2.3", + "servo_arc", + "smallvec", +] + +[[package]] +name = "lewp-selectors" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08b1dc58ea0886a660510a1be6a62677aee0f6e9892932e43d3257e2b1a58886" +dependencies = [ + "bitflags", + "cssparser", + "derive_more", + "fxhash", + "log", + "phf 0.8.0", + "phf_codegen 0.8.0", + "precomputed-hash", + "servo_arc", + "smallvec", +] + [[package]] name = "libc" version = "0.2.100" @@ -769,8 +910,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" dependencies = [ "log", - "phf", - "phf_codegen", + "phf 0.8.0", + "phf_codegen 0.8.0", "string_cache", "string_cache_codegen", "tendril", @@ -810,6 +951,7 @@ dependencies = [ "gitignore", "handlebars", "lazy_static", + "lewp-css", "log", "memchr", "notify", @@ -935,6 +1077,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -974,7 +1122,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-traits", ] @@ -984,7 +1132,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] [[package]] @@ -1019,14 +1167,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ordermap" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b81cf3b8cb96aa0e73bbedfcdc9708d09fec2854ba8d474be4e6f666d7379e8b" + [[package]] name = "os_str_bytes" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" -dependencies = [ - "memchr", -] [[package]] name = "output_vt100" @@ -1070,9 +1221,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ "pest", "pest_meta", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -1086,13 +1237,43 @@ dependencies = [ "sha-1 0.8.2", ] +[[package]] +name = "phf" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" +dependencies = [ + "phf_shared 0.7.24", +] + [[package]] name = "phf" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_macros 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", +] + +[[package]] +name = "phf_codegen" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" +dependencies = [ + "phf_generator 0.7.24", + "phf_shared 0.7.24", ] [[package]] @@ -1101,8 +1282,18 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.8.0", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf_generator" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +dependencies = [ + "phf_shared 0.7.24", + "rand 0.6.5", ] [[package]] @@ -1111,17 +1302,72 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", "rand 0.7.3", ] +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand 0.8.4", +] + +[[package]] +name = "phf_macros" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb45e833315153371697760dad1831da99ce41884162320305e4f123ca3fe37" +dependencies = [ + "phf_generator 0.7.24", + "phf_shared 0.7.24", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "phf_macros" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", +] + +[[package]] +name = "phf_shared" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +dependencies = [ + "siphasher 0.2.3", +] + [[package]] name = "phf_shared" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" dependencies = [ - "siphasher", + "siphasher 0.3.6", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher 0.3.6", ] [[package]] @@ -1139,9 +1385,9 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -1222,13 +1468,22 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.2", ] [[package]] @@ -1242,19 +1497,53 @@ dependencies = [ "unicase", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-error" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.28", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.8", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg 0.1.2", + "rand_xorshift", + "winapi 0.3.9", ] [[package]] @@ -1268,7 +1557,7 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc 0.2.0", - "rand_pcg", + "rand_pcg 0.2.1", ] [[package]] @@ -1283,6 +1572,16 @@ dependencies = [ "rand_hc 0.3.1", ] +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.3.1", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -1303,6 +1602,21 @@ dependencies = [ "rand_core 0.6.3", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.5.1" @@ -1321,6 +1635,15 @@ dependencies = [ "getrandom 0.2.3", ] +[[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_hc" version = "0.2.0" @@ -1339,6 +1662,50 @@ dependencies = [ "rand_core 0.6.3", ] +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.9", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.9", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.4.2", +] + [[package]] name = "rand_pcg" version = "0.2.1" @@ -1348,6 +1715,24 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "redox_syscall" version = "0.2.10" @@ -1389,6 +1774,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1442,9 +1836,9 @@ version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -1470,6 +1864,16 @@ dependencies = [ "serde", ] +[[package]] +name = "servo_arc" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" +dependencies = [ + "nodrop", + "stable_deref_trait", +] + [[package]] name = "sha-1" version = "0.8.2" @@ -1501,6 +1905,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42a568c8f2cd051a4d283bd6eb0343ac214c1b0f1ac19f93e1175b2dee38c73d" +[[package]] +name = "siphasher" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" + [[package]] name = "siphasher" version = "0.3.6" @@ -1513,6 +1923,12 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + [[package]] name = "socket2" version = "0.4.1" @@ -1523,6 +1939,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "string_cache" version = "0.8.1" @@ -1531,7 +1953,7 @@ checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" dependencies = [ "lazy_static", "new_debug_unreachable", - "phf_shared", + "phf_shared 0.8.0", "precomputed-hash", "serde", ] @@ -1542,10 +1964,10 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97" dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", + "phf_generator 0.8.0", + "phf_shared 0.8.0", + "proc-macro2 1.0.28", + "quote 1.0.9", ] [[package]] @@ -1554,15 +1976,26 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + [[package]] name = "syn" version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "proc-macro2 1.0.28", + "quote 1.0.9", + "unicode-xid 0.2.2", ] [[package]] @@ -1601,9 +2034,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" @@ -1620,9 +2053,9 @@ version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -1672,9 +2105,9 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.75", ] [[package]] @@ -1824,6 +2257,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.2" diff --git a/Cargo.toml b/Cargo.toml index b1c095d3c5..cc780054ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ description = "Creates a book from markdown files" [dependencies] anyhow = "1.0.28" chrono = "0.4" -clap = { version = "3.0", features = ["cargo"] } +clap = { version = "3.1.15", features = ["cargo"] } clap_complete = "3.0" env_logger = "0.9.0" handlebars = "4.0" @@ -34,6 +34,7 @@ shlex = "1" tempfile = "3.0" toml = "0.5.1" topological-sort = "0.1.0" +lewp-css = "0.2" # Watch feature notify = { version = "4.0", optional = true } diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index 974d65fae7..73133affb1 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -30,6 +30,7 @@ - [index.hbs](format/theme/index-hbs.md) - [Syntax highlighting](format/theme/syntax-highlighting.md) - [Editor](format/theme/editor.md) + - [Custom fonts](format/custom-fonts.md) - [MathJax Support](format/mathjax.md) - [mdBook-specific features](format/mdbook.md) - [Markdown](format/markdown.md) diff --git a/guide/src/format/custom-fonts.md b/guide/src/format/custom-fonts.md new file mode 100644 index 0000000000..281606c30d --- /dev/null +++ b/guide/src/format/custom-fonts.md @@ -0,0 +1,59 @@ +# Custom fonts + +It is possible to use custom fonts by using a combination of the parameters +`copy-fonts` and `copy-custom-fonts`. `copy-fonts` is enabled by default. + +The fonts are specified by the `fonts/fonts.css` file, relative to the root directory +of your book project. + +## The copy-fonts option + +If `copy-fonts` is enabled, the build in `fonts/fonts.css` file is being copied +to the output directory. In addition to that, the default fonts are copied to +the output directory. + +## The copy-custom-fonts option + +If `copy-custom-fonts` is enabled, the `fonts/fonts.css` file that you have created +is copied to the output directory. Also, the file gets parsed and searched for +`@font-face` rules having a `src: url(CUSTOM-FONT)` definition. These `CUSTOM-FONT` +files are copied to the output directory. + +## Enabling both options + +It is also possible to use both options in parallel. Then, the build in fonts +are copied, as well as the custom font files that have been found. The build in +and the custom definition of `fonts/fonts.css` are combined and copied to the +output directory as well. + +## Example with both options enabled + +Create a `fonts/` folder in your book root. Then copy the fonts you want to use +into this folder (in this example we are assuming `Lato-Regular.ttf`) + +Create a custom fonts file `fonts/fonts.css` + +```css +@font-face { + font-family: "Lato"; + font-style: normal; + font-weight: normal; + src: url('Lato-Regular.ttf'); +} +``` + +Setup your `book.toml` that it contains the following parameters: + +```toml +[output.html] +copy-fonts = true +copy-custom-fonts = true +``` + +Adjust your `theme/css/general.css` file according to your needs, for example: + +```css +html { + font-family: "Lato", sans-serif; +} +``` diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 5fe73236ca..bf8e431d90 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1,11 +1,11 @@ use crate::{get_book_dir, open}; -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command}; use mdbook::errors::Result; use mdbook::MDBook; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("build") +pub fn make_subcommand<'help>() -> Command<'help> { + Command::new("build") .about("Builds a book from its markdown files") .arg( Arg::new("dest-dir") diff --git a/src/cmd/clean.rs b/src/cmd/clean.rs index 0569726e1b..51dce46a06 100644 --- a/src/cmd/clean.rs +++ b/src/cmd/clean.rs @@ -1,12 +1,12 @@ use crate::get_book_dir; use anyhow::Context; -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command}; use mdbook::MDBook; use std::fs; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("clean") +pub fn make_subcommand<'help>() -> Command<'help> { + Command::new("clean") .about("Deletes a built book") .arg( Arg::new("dest-dir") diff --git a/src/cmd/init.rs b/src/cmd/init.rs index c964dcc137..80513255f3 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -1,5 +1,5 @@ use crate::get_book_dir; -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command as ClapCommand}; use mdbook::config; use mdbook::errors::Result; use mdbook::MDBook; @@ -8,8 +8,8 @@ use std::io::Write; use std::process::Command; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("init") +pub fn make_subcommand<'help>() -> ClapCommand<'help> { + ClapCommand::new("init") .about("Creates the boilerplate structure and files for a new book") // the {n} denotes a newline which will properly aligned in all help messages .arg(arg!([dir] diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 00eaa46b4d..e207ac3622 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -1,7 +1,7 @@ #[cfg(feature = "watch")] use super::watch; use crate::{get_book_dir, open}; -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command}; use futures_util::sink::SinkExt; use futures_util::StreamExt; use mdbook::errors::*; @@ -18,8 +18,8 @@ use warp::Filter; const LIVE_RELOAD_ENDPOINT: &str = "__livereload"; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("serve") +pub fn make_subcommand<'help>() -> Command<'help> { + Command::new("serve") .about("Serves a book at http://localhost:3000, and rebuilds it on changes") .arg( Arg::new("dest-dir") diff --git a/src/cmd/test.rs b/src/cmd/test.rs index f5ca3ee419..12e0e8eba1 100644 --- a/src/cmd/test.rs +++ b/src/cmd/test.rs @@ -1,11 +1,11 @@ use crate::get_book_dir; -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command}; use mdbook::errors::Result; use mdbook::MDBook; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("test") +pub fn make_subcommand<'help>() -> Command<'help> { + Command::new("test") .about("Tests that a book's Rust code samples compile") .arg( Arg::new("dest-dir") @@ -37,8 +37,8 @@ pub fn make_subcommand<'help>() -> App<'help> { .long("library-path") .value_name("dir") .takes_value(true) - .use_delimiter(true) - .require_delimiter(true) + .use_value_delimiter(true) + .require_value_delimiter(true) .multiple_values(true) .multiple_occurrences(true) .forbid_empty_values(true) diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 9336af779a..b3debc3471 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -1,5 +1,5 @@ use crate::{get_book_dir, open}; -use clap::{arg, App, Arg, ArgMatches}; +use clap::{arg, Arg, ArgMatches, Command}; use mdbook::errors::Result; use mdbook::utils; use mdbook::MDBook; @@ -10,8 +10,8 @@ use std::thread::sleep; use std::time::Duration; // Create clap subcommand arguments -pub fn make_subcommand<'help>() -> App<'help> { - App::new("watch") +pub fn make_subcommand<'help>() -> Command<'help> { + Command::new("watch") .about("Watches a book's files and rebuilds it on changes") .arg( Arg::new("dest-dir") diff --git a/src/config.rs b/src/config.rs index 6b8f141461..a31220196e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -489,6 +489,9 @@ pub struct HtmlConfig { pub mathjax_support: bool, /// Whether to fonts.css and respective font files to the output directory. pub copy_fonts: bool, + /// If true, find custom font files by parsing the fonts/fonts.css and copy + /// them to the output directory. + pub copy_custom_fonts: bool, /// An optional google analytics code. pub google_analytics: Option, /// Additional CSS stylesheets to include in the rendered page's ``. @@ -549,6 +552,7 @@ impl Default for HtmlConfig { curly_quotes: false, mathjax_support: false, copy_fonts: true, + copy_custom_fonts: false, google_analytics: None, additional_css: Vec::new(), additional_js: Vec::new(), diff --git a/src/main.rs b/src/main.rs index 35562e64bb..82c5739729 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ extern crate log; use anyhow::anyhow; use chrono::Local; -use clap::{App, AppSettings, Arg, ArgMatches}; +use clap::{Arg, ArgMatches, Command}; use clap_complete::Shell; use env_logger::Builder; use log::LevelFilter; @@ -61,13 +61,13 @@ fn main() { } /// Create a list of valid arguments and sub-commands -fn create_clap_app() -> App<'static> { - let app = App::new(crate_name!()) +fn create_clap_app() -> Command<'static> { + let app = Command::new(crate_name!()) .about(crate_description!()) .author("Mathieu David ") .version(VERSION) - .setting(AppSettings::PropagateVersion) - .setting(AppSettings::ArgRequiredElseHelp) + .propagate_version(true) + .arg_required_else_help(true) .after_help( "For more information about a specific command, try `mdbook --help`\n\ The source code for mdBook is available at: https://github.com/rust-lang/mdBook", @@ -77,7 +77,7 @@ fn create_clap_app() -> App<'static> { .subcommand(cmd::test::make_subcommand()) .subcommand(cmd::clean::make_subcommand()) .subcommand( - App::new("completions") + Command::new("completions") .about("Generate shell completions for your shell to stdout") .arg( Arg::new("shell") diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 9c126feb89..ad65258fd3 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -289,6 +289,24 @@ impl HtmlHandlebars { theme::fonts::SOURCE_CODE_PRO.1, )?; } + if html_config.copy_custom_fonts { + let mut custom_fonts_css = std::fs::read(&Path::new("fonts/fonts.css"))?; + if html_config.copy_fonts { + // we need to extend the custom fonts file by the build in one + // to have the build in ones still available + custom_fonts_css.extend(theme::fonts::CSS); + } + write_file(destination, "fonts/fonts.css", &custom_fonts_css)?; + let custom_font_file_names = + helpers::custom_fonts::find_custom_font_files(Path::new("fonts/fonts.css"))?; + for font_file in custom_font_file_names { + write_file( + &Path::new(destination).join("fonts"), + &font_file, + &std::fs::read(&Path::new("fonts").join(&font_file))?, + )?; + } + } let playground_config = &html_config.playground; @@ -658,6 +676,10 @@ fn make_data( data.insert("copy_fonts".to_owned(), json!(true)); } + if html_config.copy_custom_fonts { + data.insert("copy_custom_fonts".to_owned(), json!(true)); + } + // Add check to see if there is an additional style if !html_config.additional_css.is_empty() { let mut css = Vec::new(); diff --git a/src/renderer/html_handlebars/helpers/custom_fonts.rs b/src/renderer/html_handlebars/helpers/custom_fonts.rs new file mode 100644 index 0000000000..ed47f94010 --- /dev/null +++ b/src/renderer/html_handlebars/helpers/custom_fonts.rs @@ -0,0 +1,42 @@ +use crate::errors::Result; +use lewp_css::{ + domain::{ + at_rules::font_face::{FontFaceAtRule, FontUrlSource, Source}, + CssRule, + }, + Stylesheet, +}; +use std::path::{Path, PathBuf}; + +/// Parses the given file_name and extracts the given font file names. +pub fn find_custom_font_files(css_file_name: &Path) -> Result> { + let stylesheet = std::fs::read_to_string(css_file_name)?; + let stylesheet = Stylesheet::parse(&stylesheet).unwrap_or_else(|_| { + panic!( + "Stylesheet: \"{}\" could not be parsed!", + css_file_name.display() + ) + }); + let css_rules = stylesheet.rules.0; + let mut file_names = vec![]; + for rule in css_rules { + match rule { + CssRule::FontFace(font) => { + if let Some(f) = extract_font_file_name(font) { + file_names.push(f); + } + } + _ => continue, + } + } + Ok(file_names) +} + +/// Extracts the first file name given in an URL statement from the rule. +pub fn extract_font_file_name(at_rule: FontFaceAtRule) -> Option { + at_rule.sources.as_ref()?; + match at_rule.sources.unwrap().get(0) { + Some(Source::Url(FontUrlSource { url, .. })) => Some(PathBuf::from(url.0.clone())), + _ => None, + } +} diff --git a/src/renderer/html_handlebars/helpers/mod.rs b/src/renderer/html_handlebars/helpers/mod.rs index 52be6d204b..d8d1c62c67 100644 --- a/src/renderer/html_handlebars/helpers/mod.rs +++ b/src/renderer/html_handlebars/helpers/mod.rs @@ -1,3 +1,4 @@ +pub mod custom_fonts; pub mod navigation; pub mod theme; pub mod toc; diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 0321e1413f..598664ff6b 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -35,7 +35,7 @@ - {{#if copy_fonts}} + {{#if (or copy_fonts copy_custom_fonts)}} {{/if}}