diff --git a/Cargo.lock b/Cargo.lock index 353f0add0c..10c9eb40e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,15 +25,14 @@ dependencies = [ [[package]] name = "ammonia" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b74b175af97d1aecc1add0878b1cbfcbf3bd4c22d7713eeb6d597da23e29bc0d" +checksum = "ea9f21d23d82bae9d33c21080572af1fa749788e68234b5d8fa5e39d3e0783ed" dependencies = [ "html5ever", "lazy_static", "maplit", "markup5ever_rcdom", - "matches", "tendril", "url", ] @@ -55,9 +54,9 @@ checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" [[package]] name = "anyhow" -version = "1.0.53" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" +checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd" [[package]] name = "arrayvec" @@ -97,9 +96,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" @@ -142,9 +141,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ "generic-array 0.14.5", ] @@ -224,9 +223,9 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" dependencies = [ "jobserver", ] @@ -305,9 +304,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.13" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08799f92c961c7a1cf0cc398a9073da99e21ce388b46372c37f3191f2f3eed3e" +checksum = "5177fac1ab67102d8989464efd043c6ff44191b1557ec1ddd489b4f7e1447e77" dependencies = [ "atty", "bitflags", @@ -322,18 +321,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "3.0.5" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4dabb7e2f006497e1da045feaa512acf0686f76b68d94925da2d9422dcb521" +checksum = "23eec4dd324308f49d8bf86a2732078c34d57955fec1e1d865554fc37c15d420" dependencies = [ - "clap 3.0.13", + "clap 3.1.2", ] [[package]] name = "clap_derive" -version = "3.0.12" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd2078197a22f338bd4fbf7d6387eb6f0d6a3c69e6cbc09f5c93e97321fd92a" +checksum = "01d42c94ce7c2252681b5fed4d3627cc807b13dfc033246bd05d5b252399000e" dependencies = [ "heck 0.4.0", "proc-macro-error", @@ -369,11 +368,24 @@ dependencies = [ "utils", ] +[[package]] +name = "console" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "terminal_size", + "winapi 0.3.9", +] + [[package]] name = "core-foundation" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -396,9 +408,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if 1.0.0", ] @@ -426,9 +438,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762" +checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -439,9 +451,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" +checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -449,11 +461,12 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ "generic-array 0.14.5", + "typenum", ] [[package]] @@ -488,15 +501,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "deflate" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f95bf05dffba6e6cce8dfbb30def788154949ccd9aed761b472119c21e01c70" -dependencies = [ - "adler32", -] - [[package]] name = "deflate" version = "1.0.0" @@ -529,13 +533,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "block-buffer 0.10.0", + "block-buffer 0.10.2", "crypto-common", - "generic-array 0.14.5", ] [[package]] @@ -569,6 +572,12 @@ dependencies = [ "strum_macros", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding" version = "0.2.33" @@ -656,7 +665,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4badb9489a465cb2c555af1f00f0bfd8cecd6fc12ac11da9d5b40c5dd5f0200" dependencies = [ "bit_field", - "deflate 1.0.0", + "deflate", "flume", "half", "inflate", @@ -701,14 +710,14 @@ dependencies = [ "cfg-if 1.0.0", "crc32fast", "libc", - "miniz_oxide", + "miniz_oxide 0.4.4", ] [[package]] name = "flume" -version = "0.10.10" +version = "0.10.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d04dafd11240188e146b6f6476a898004cace3be31d4ec5e08e216bf4947ac0" +checksum = "0b279436a715a9de95dcd26b151db590a71961cc06e54918b24fe0dd5b7d3fc4" dependencies = [ "futures-core", "futures-sink", @@ -796,9 +805,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futf" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b" +checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" dependencies = [ "mac", "new_debug_unreachable", @@ -806,42 +815,42 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-io" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-sink" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-core", "futures-io", @@ -893,9 +902,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1047,9 +1056,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" +checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" [[package]] name = "httpdate" @@ -1065,9 +1074,9 @@ checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" [[package]] name = "hyper" -version = "0.14.16" +version = "0.14.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" +checksum = "043f0e083e9901b6cc658a77d1eb86f4fc650bbb977a4337dd63192826aa85dd" dependencies = [ "bytes 1.1.0", "futures-channel", @@ -1078,7 +1087,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 0.4.8", + "itoa 1.0.1", "pin-project-lite", "socket2", "tokio", @@ -1144,16 +1153,16 @@ dependencies = [ [[package]] name = "image" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94ac3d41f882c624a82d7945952032388488681f45f9d4077999a6c85688d61" +checksum = "db207d030ae38f1eb6f240d5a1c1c88ff422aa005d10f8c6c6fc5e75286ab30e" dependencies = [ "bytemuck", "byteorder", "color_quant", "exr", "gif", - "jpeg-decoder 0.2.1", + "jpeg-decoder 0.2.2", "num-iter", "num-rational", "num-traits", @@ -1213,6 +1222,20 @@ dependencies = [ "libc", ] +[[package]] +name = "insta" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c0c443f6dceb3a1cb7607c87501aa91e4b9c976044f725c2a74ca2152c91a4" +dependencies = [ + "console", + "once_cell", + "serde", + "serde_json", + "serde_yaml", + "similar", +] + [[package]] name = "instant" version = "0.1.12" @@ -1281,9 +1304,9 @@ checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" [[package]] name = "jpeg-decoder" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbcf0244f6597be39ab8d9203f574cafb529ae8c698afa2182f7b3c3205a4a9c" +checksum = "105fb082d64e2100074587f59a74231f771750c664af903f1f9f76c9dedfc6f1" dependencies = [ "rayon", ] @@ -1349,9 +1372,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.116" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "library" @@ -1609,9 +1632,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mime_guess" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" dependencies = [ "mime", "unicase", @@ -1638,6 +1661,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.6.23" @@ -1659,9 +1691,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.14" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" dependencies = [ "libc", "log", @@ -1715,7 +1747,7 @@ dependencies = [ "httparse", "lazy_static", "log", - "rand 0.8.4", + "rand 0.8.5", "regex", "serde_json", "serde_urlencoded", @@ -1727,7 +1759,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "729eb334247daa1803e0a094d0a5c55711b85571179f5ec6e53eccfdf7008958" dependencies = [ - "getrandom 0.2.4", + "getrandom 0.2.5", ] [[package]] @@ -1871,9 +1903,9 @@ dependencies = [ [[package]] name = "ntapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" dependencies = [ "winapi 0.3.9", ] @@ -1984,9 +2016,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "open" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176ee4b630d174d2da8241336763bb459281dddc0f4d87f72c3b1efc9a6109b7" +checksum = "5a82915836ef43159bb6a3c64d884c42329ccd0b8afdca737cf1e3dd701709dc" dependencies = [ "pathdiff", "winapi 0.3.9", @@ -2042,7 +2074,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.1", ] [[package]] @@ -2059,6 +2101,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "parking_lot_core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -2184,7 +2239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared 0.10.0", - "rand 0.8.4", + "rand 0.8.5", ] [[package]] @@ -2260,15 +2315,14 @@ dependencies = [ [[package]] name = "png" -version = "0.17.2" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c845088517daa61e8a57eee40309347cea13f273694d1385c553e7a57127763b" +checksum = "8e8f1882177b17c98ec33a51f5910ecbf4db92ca0def706781a1f8d0c661f393" dependencies = [ "bitflags", "crc32fast", - "deflate 0.9.1", - "encoding", - "miniz_oxide", + "deflate", + "miniz_oxide 0.5.1", ] [[package]] @@ -2352,20 +2406,19 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", "rand_pcg", ] [[package]] name = "rand" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.3", - "rand_hc 0.3.1", ] [[package]] @@ -2403,7 +2456,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.4", + "getrandom 0.2.5", ] [[package]] @@ -2415,15 +2468,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", -] - [[package]] name = "rand_pcg" version = "0.2.1" @@ -2492,9 +2536,9 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "relative-path" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d4caf086b102ab49d0525b721594a555ab55c6556086bbe52a430ad26c3bd7" +checksum = "a49a831dc1e13c9392b660b162333d4cb0033bbbdfe6a1687177e59e89037c86" [[package]] name = "remove_dir_all" @@ -2512,6 +2556,7 @@ dependencies = [ "config", "errors", "front_matter", + "insta", "libs", "link_checker", "pest", @@ -2598,9 +2643,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.2" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" +checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" dependencies = [ "log", "ring", @@ -2704,9 +2749,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" dependencies = [ "bitflags", "core-foundation", @@ -2717,9 +2762,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ "core-foundation-sys", "libc", @@ -2747,9 +2792,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ "indexmap", "itoa 1.0.1", @@ -2795,13 +2840,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.1", + "digest 0.10.3", ] [[package]] @@ -2813,6 +2858,12 @@ dependencies = [ "libc", ] +[[package]] +name = "similar" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3" + [[package]] name = "siphasher" version = "0.3.9" @@ -2901,14 +2952,14 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_cache" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "923f0f39b6267d37d23ce71ae7235602134b250ace715dd2c90421998ddac0c6" +checksum = "33994d0838dc2d152d17a62adf608a869b5e846b65b389af7f3dbc1de45c5b26" dependencies = [ "lazy_static", "new_debug_unreachable", - "parking_lot", - "phf_shared 0.8.0", + "parking_lot 0.11.2", + "phf_shared 0.10.0", "precomputed-hash", "serde", ] @@ -3066,7 +3117,7 @@ dependencies = [ "percent-encoding", "pest", "pest_derive", - "rand 0.8.4", + "rand 0.8.5", "regex", "serde", "serde_json", @@ -3083,11 +3134,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "test-case" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cad0a06f9a61e94355aa3b3dc92d85ab9c83406722b1ca5e918d4297c12c23" +checksum = "e9e5f048404b43e8ae66dce036163515b6057024cf58c6377be501f250bd3c6a" dependencies = [ "cfg-if 1.0.0", "proc-macro2", @@ -3204,19 +3265,20 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.16.1" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ "bytes 1.1.0", "libc", "memchr", - "mio 0.7.14", + "mio 0.8.0", "num_cpus", "once_cell", - "parking_lot", + "parking_lot 0.12.0", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", "winapi 0.3.9", ] @@ -3284,9 +3346,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -3295,9 +3357,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" dependencies = [ "lazy_static", ] @@ -3423,9 +3485,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "unicode-width" @@ -3678,6 +3740,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" + [[package]] name = "winreg" version = "0.7.0" @@ -3698,9 +3803,9 @@ dependencies = [ [[package]] name = "ws" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" +checksum = "25fe90c75f236a0a00247d5900226aea4f2d7b05ccc34da9e7a8880ff59b5848" dependencies = [ "byteorder", "bytes 0.4.12", @@ -3777,7 +3882,7 @@ name = "zola" version = "0.16.0" dependencies = [ "atty", - "clap 3.0.13", + "clap 3.1.2", "clap_complete", "ctrlc", "errors", diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index 42e4f55c9d..d134ca5d1a 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -204,13 +204,8 @@ impl Taxonomy { // Check for taxon-specific template, or use generic as fallback. let specific_template = format!("{}/single.html", self.kind.name); - let template = if let Some(template) = - check_template_fallbacks(&specific_template, tera, &config.theme) - { - template - } else { - "taxonomy_single.html" - }; + let template = check_template_fallbacks(&specific_template, tera, &config.theme) + .unwrap_or("taxonomy_single.html"); render_template(template, tera, context, &config.theme).map_err(|e| { Error::chain(format!("Failed to render single term {} page.", self.kind.name), e) diff --git a/components/rendering/Cargo.toml b/components/rendering/Cargo.toml index 58c6c49e45..8c4496057b 100644 --- a/components/rendering/Cargo.toml +++ b/components/rendering/Cargo.toml @@ -18,4 +18,4 @@ libs = { path = "../libs" } [dev-dependencies] templates = { path = "../templates" } - +insta = "1.12.0" diff --git a/components/rendering/src/shortcode/parser.rs b/components/rendering/src/shortcode/parser.rs index fefecd7291..9ccc8ad2de 100644 --- a/components/rendering/src/shortcode/parser.rs +++ b/components/rendering/src/shortcode/parser.rs @@ -481,10 +481,10 @@ mod tests { fn can_handle_multiple_shortcodes() { let (_, shortcodes) = parse_for_shortcodes( r#" - {{ youtube(id="ub36ffWAqgQ") }} + {{ youtube(id="ub36ffWAqgQ_hey_") }} {{ youtube(id="ub36ffWAqgQ", autoplay=true) }} - {{ vimeo(id="210073083") }} - {{ streamable(id="c0ic") }} + {{ vimeo(id="210073083#hello", n_a_me="hello") }} + {{ streamable(id="c0ic", n1=true) }} {{ gist(url="https://gist.github.com/Keats/32d26f699dcc13ebd41b") }}"#, ) .unwrap(); diff --git a/components/rendering/tests/codeblock_hide_lines.rs b/components/rendering/tests/codeblock_hide_lines.rs deleted file mode 100644 index 37ee279a29..0000000000 --- a/components/rendering/tests/codeblock_hide_lines.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::collections::HashMap; - -use libs::tera::Tera; - -use config::Config; -use front_matter::InsertAnchor; -use rendering::{render_content, RenderContext}; - -macro_rules! colored_html_line { - ( $s:expr ) => {{ - let mut result = "".to_string(); - result.push_str($s); - result.push_str("\n"); - result - }}; -} - -macro_rules! colored_html { - ( $($s:expr),* $(,)* ) => {{ - let mut result = "
".to_string();
- $(
- result.push_str(colored_html_line!($s).as_str());
- )*
- result.push_str("
\n");
- result
- }};
-}
-
-#[test]
-fn hide_lines_simple() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hide_lines=2
-foo
-bar
-baz
-bat
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(res.body, colored_html!("foo", "baz", "bat"));
-}
diff --git a/components/rendering/tests/codeblock_hl_lines.rs b/components/rendering/tests/codeblock_hl_lines.rs
deleted file mode 100644
index 700818082d..0000000000
--- a/components/rendering/tests/codeblock_hl_lines.rs
+++ /dev/null
@@ -1,515 +0,0 @@
-use std::collections::HashMap;
-
-use libs::tera::Tera;
-
-use config::Config;
-use front_matter::InsertAnchor;
-use rendering::{render_content, RenderContext};
-
-macro_rules! colored_html_line {
- ( @no $s:expr ) => {{
- let mut result = "".to_string();
- result.push_str($s);
- result.push_str("\n");
- result
- }};
- ( @hl $s:expr ) => {{
- let mut result = "".to_string();
- result.push_str("");
- result.push_str($s);
- result.push_str("\n");
- result.push_str("");
- result
- }};
-}
-
-macro_rules! colored_html {
- ( $(@$kind:tt $s:expr),* $(,)* ) => {{
- let mut result = "".to_string();
- $(
- result.push_str(colored_html_line!(@$kind $s).as_str());
- )*
- result.push_str("
\n");
- result
- }};
-}
-
-#[test]
-fn hl_lines_simple() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=2
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @no "foo",
- @hl "bar",
- @no "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_in_middle() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=2-3
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @no "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_all() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=1-4
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @hl "bar",
- @hl "bar",
- @hl "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_start_from_one() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=1-3
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_start_from_zero() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=0-3
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_end() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=3-4
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @no "foo",
- @no "bar",
- @hl "bar",
- @hl "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_end_out_of_bounds() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=3-4294967295
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @no "foo",
- @no "bar",
- @hl "bar",
- @hl "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_overlap() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=2-3 1-2
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
-#[test]
-fn hl_lines_multiple() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=2-3,hl_lines=1-2
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_extra_spaces() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-``` hl_lines = 2 - 3 1 - 2
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_int_and_range() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=1 3-4
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @hl "foo",
- @no "bar",
- @hl "bar",
- @hl "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_single_line_range() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=2-2
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @no "foo",
- @hl "bar",
- @no "bar",
- @no "baz",
- )
- );
-}
-
-#[test]
-fn hl_lines_reverse_range() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```hl_lines=3-2
-foo
-bar
-bar
-baz
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- colored_html!(
- @no "foo",
- @hl "bar",
- @hl "bar",
- @no "baz",
- )
- );
-}
diff --git a/components/rendering/tests/codeblock_linenos.rs b/components/rendering/tests/codeblock_linenos.rs
deleted file mode 100644
index d974c32c6c..0000000000
--- a/components/rendering/tests/codeblock_linenos.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-use std::collections::HashMap;
-
-use libs::tera::Tera;
-
-use config::Config;
-use front_matter::InsertAnchor;
-use rendering::{render_content, RenderContext};
-
-#[test]
-fn can_add_line_numbers() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```linenos
-foo
-bar
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- "1 foo\n 2 bar\n
\n"
- );
-}
-
-#[test]
-fn can_add_line_numbers_with_linenostart() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```linenos, linenostart=40
-foo
-bar
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- "40 foo\n 41 bar\n
\n"
- );
-}
-
-#[test]
-fn can_add_line_numbers_with_highlight() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content(
- r#"
-```linenos, hl_lines=2
-foo
-bar
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- "1 foo\n 2 bar\n
\n"
- );
-}
diff --git a/components/rendering/tests/codeblock_shortcode_mix.rs b/components/rendering/tests/codeblock_shortcode_mix.rs
deleted file mode 100644
index 59bb615827..0000000000
--- a/components/rendering/tests/codeblock_shortcode_mix.rs
+++ /dev/null
@@ -1,271 +0,0 @@
-use std::collections::HashMap;
-
-use config::Config;
-use front_matter::InsertAnchor;
-use rendering::{render_content, RenderContext};
-use templates::ZOLA_TERA;
-
-#[test]
-fn can_render_shortcode_in_codeblock() {
- let permalinks_ctx = HashMap::new();
- let config = Config::default_for_test();
- let mut context = RenderContext::new(
- &ZOLA_TERA,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let shortcode_def = utils::templates::get_shortcodes(&ZOLA_TERA);
- context.set_shortcode_definitions(&shortcode_def);
- // simple case
- let res = render_content(
- r#"
-```
-{{ youtube(id="dQw4w9WgXcQ") }}
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- "<div >\n <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n</div>\n\n
\n"
- );
- // mixed with other contents
- let res = render_content(
- r#"
-```
-<div id="custom-attr">\n<div >\n <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n</div>\n\n</div>\n
\n"
- );
- // mixed content with syntax and line numbers
- let res = render_content(
- r#"
-```html,linenos
-1 <div id="custom-attr">\n 2 <div >\n 3 <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n 4 </div>\n 5 \n 6 </div>\n
\n"
- );
-}
-
-#[test]
-fn can_render_multiple_shortcodes_in_codeblock() {
- let permalinks_ctx = HashMap::new();
- let config = Config::default_for_test();
- let mut context = RenderContext::new(
- &ZOLA_TERA,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let shortcode_def = utils::templates::get_shortcodes(&ZOLA_TERA);
- context.set_shortcode_definitions(&shortcode_def);
- // simple case
- let res = render_content(
- r#"
-```
-{{ youtube(id="dQw4w9WgXcQ") }}
-{{ gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57", class="gist") }}
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- "<div >\n <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n</div>\n\n<div class="gist">\n <script src="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57.js"></script>\n</div>\n\n
\n"
- );
- // mixed with other contents
- let res = render_content(
- r#"
-```
-text 1
-{{ youtube(id="dQw4w9WgXcQ") }}
-text 2
-{{ gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57", class="gist") }}
-text 3
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- "text 1\n<div >\n <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n</div>\n\ntext 2\n<div class="gist">\n <script src="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57.js"></script>\n</div>\n\ntext 3\n
\n"
- );
- // mixed content with syntax and line numbers
- let res = render_content(
- r#"
-```html,linenos
-text 1
-{{ youtube(id="dQw4w9WgXcQ") }}
-text 2
-{{ gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57", class="gist") }}
-text 3
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- r#"1 <span>text 1</span>
- 2 <div >
- 3 <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
- 4 </div>
- 5
- 6 <span>text 2</span>
- 7 <div class="gist">
- 8 <script src="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57.js"></script>
- 9 </div>
- 10
- 11 <span>text 3</span>
-
-"#
- );
-}
-
-#[test]
-fn is_highlighting_linenos_still_working() {
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let mut context = RenderContext::new(
- &ZOLA_TERA,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let shortcode_def = utils::templates::get_shortcodes(&ZOLA_TERA);
- context.set_shortcode_definitions(&shortcode_def);
- // single shortcode mixed with syntax and line numbers
- let res = render_content(
- r#"
-```html,linenos
-1 <div id="custom-attr">\n 2 <div >\n 3 <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n 4 </div>\n 5 \n 6 </div>\n
\n"
- );
- // multiple shortcode mixed with syntax and line numbers
- let res = render_content(
- r#"
-```html,linenos
-text 1
-{{ youtube(id="dQw4w9WgXcQ") }}
-text 2
-{{ gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57", class="gist") }}
-text 3
-```
- "#,
- &context,
- )
- .unwrap();
- assert_eq!(
- res.body,
- r#"1 <span>text 1</span>
- 2 <div >
- 3 <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
- 4 </div>
- 5
- 6 <span>text 2</span>
- 7 <div class="gist">
- 8 <script src="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57.js"></script>
- 9 </div>
- 10
- 11 <span>text 3</span>
-
-"#
- );
-}
-
-#[test]
-fn codeblock_shortcode_mix_all_stars() {
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let mut context = RenderContext::new(
- &ZOLA_TERA,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let shortcode_def = utils::templates::get_shortcodes(&ZOLA_TERA);
- context.set_shortcode_definitions(&shortcode_def);
- // single shortcode mixed with syntax and line numbers
- let res = render_content(
- r#"
-```html,linenos
-{{/* before(texts="1") */}}
-Normally people would not write something & like <> this:
-1 <a href="javascript:void(0);">{{ before(texts="1") }}</a>
- 2 Normally people would not write something & like <> this:
- 3 <div id="custom-attr">
- 4 An inline <div class="youtube">
- 5 <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?autoplay=1" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
- 6 </div>
- 7 shortcode
- 8 </div>
- 9 Plain text in-between
- 10 {% quote(author="Vincent") %}
- 11 A quote
- 12 {% end %}
- 13 <div class="gist">
- 14 <script src="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57.js"></script>
- 15 </div>
- 16
- 17 {# A Tera comment, you should see it #}
- 18 <!-- end text goes here -->
-
-"#
- );
-}
diff --git a/components/rendering/tests/codeblocks.rs b/components/rendering/tests/codeblocks.rs
new file mode 100644
index 0000000000..6aa9dc7424
--- /dev/null
+++ b/components/rendering/tests/codeblocks.rs
@@ -0,0 +1,337 @@
+use config::Config;
+
+mod common;
+
+fn render_codeblock(content: &str, highlight_code: bool) -> String {
+ let mut config = Config::default_for_test();
+ config.markdown.highlight_code = highlight_code;
+ common::render_with_config(content, config).unwrap().body
+}
+
+#[test]
+fn does_nothing_with_highlighting_disabled() {
+ let body = render_codeblock(
+ r#"
+```
+foo
+bar
+```
+ "#,
+ false,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_hide_lines() {
+ let body = render_codeblock(
+ r#"
+```hide_lines=2
+foo
+bar
+baz
+bat
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_single_line() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=2
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_line_range() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=2-3
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_all_lines() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=1-4
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_zero_start_same_as_one() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=0-3
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ let body2 = render_codeblock(
+ r#"
+```hl_lines=1-3
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ assert_eq!(body, body2);
+}
+
+#[test]
+fn can_highlight_at_end() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=3-4
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_out_of_bounds() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=3-4567898765
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_ranges_overlap() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=2-3 1-2
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_weird_fence_tokens() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=2-3, hl_lines = 1 - 2
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_mix_line_ranges() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=1 3-4
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_single_line_range() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=2-2
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_highlight_reversed_range() {
+ let body = render_codeblock(
+ r#"
+```hl_lines=3-2
+foo
+bar
+bar
+baz
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_add_line_numbers() {
+ let body = render_codeblock(
+ r#"
+```linenos
+foo
+bar
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_add_line_numbers_with_lineno_start() {
+ let body = render_codeblock(
+ r#"
+```linenos, linenostart=40
+foo
+bar
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_add_line_numbers_with_highlight() {
+ let body = render_codeblock(
+ r#"
+```linenos, hl_lines=2
+foo
+bar
+```
+ "#,
+ true,
+ );
+ insta::assert_snapshot!(body);
+}
+
+#[test]
+fn can_render_shortcode_in_codeblock() {
+ let body = render_codeblock(
+ r#"
+```html,linenos
+{{ body | safe}}
a: {{ nth }}
").unwrap(); + tera.add_raw_template("shortcodes/b.html", "b: {{ nth }}
").unwrap(); + tera.add_raw_template("shortcodes/quote.html", "{{body}}").unwrap(); + tera.add_raw_template("shortcodes/pre.html", "
{{body}}").unwrap(); + tera.add_raw_template("shortcodes/four_spaces.html", " no highlight\n or there").unwrap(); + tera.add_raw_template("shortcodes/i18n.html", "{{lang}}").unwrap(); + tera.add_raw_template( + "shortcodes/book.md", + "![Book cover in {{ lang }}](cover.{{ lang }}.png)", + ) + .unwrap(); + tera.add_raw_template("shortcodes/md_passthrough.md", "{{body}}").unwrap(); + + let mut permalinks = HashMap::new(); + permalinks.insert("pages/about.md".to_owned(), "https://getzola.org/about/".to_owned()); + + tera.register_filter( + "markdown", + templates::filters::MarkdownFilter::new(PathBuf::new(), config.clone(), permalinks.clone()) + .unwrap(), + ); + let mut context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks, + insert_anchor, + ); + let shortcode_def = utils::templates::get_shortcodes(&tera); + context.set_shortcode_definitions(&shortcode_def); + context.set_current_page_path("my_page.md"); + + render_content(content, &context) +} + +pub fn render(content: &str) -> Result
-{{ body }}", - false, - )]; - - let mut permalinks = std::collections::HashMap::new(); - - permalinks.insert("".to_string(), "".to_string()); - - // Add all shortcodes - for ShortCode { name, is_md, output } in shortcodes.into_iter() { - tera.add_raw_template( - &format!("shortcodes/{}.{}", name, if is_md { "md" } else { "html" }), - &output, - ) - .unwrap(); - } - - let mut context = rendering::RenderContext::new( - &tera, - &config, - &config.default_language, - "", - &permalinks, - front_matter::InsertAnchor::None, - ); - let shortcode_def = utils::templates::get_shortcodes(&tera); - context.set_shortcode_definitions(&shortcode_def); - - let rendered = rendering::render_content(COMPLETE_PAGE, &context); - assert!(rendered.is_ok(), "Rendering failed"); - - let rendered = rendered.unwrap(); - - let asserted_internal_links: Vec<(String, Option
--- {{ author}} -
This is bold text
-This is bold text
-This is italic text
-This is italic text
-Strikethrough
--Blockquotes can also be nested...
---...by using additional greater-than signs right next to each other...
---...or with spaces between arrows.
-
Unordered
-+
, -
, or *
Ordered
-Lorem ipsum dolor sit amet
-Consectetur adipiscing elit
-Integer molestie lorem at massa
-You can use sequential numbers...
-...or keep all the numbers as 1.
Start numbering with offset:
-Inline code
Indented code
-// Some comments
-line 1 of code
-line 2 of code
-line 3 of code
-
-Block code "fences"
-Sample text here...
-
-Syntax highlighting
-var foo = function (bar) {
- return bar++;
-};
-
-console.log(foo(5));
-
--This is a test quote! -1900-01-01
--- John Doe -
Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
Right aligned columns
-Option | Description |
---|---|
data | path to data files to supply the data that will be passed into templates. |
engine | engine to be used for processing templates. Handlebars is the default. |
ext | extension to be used for dest files. |
-
-Like links, Images also have a footnote style syntax
- -With a reference later in the document defining the URL location:
-Footnote 1 link1.
-Footnote 2 link2.
-Duplicated footnote reference2.
-Footnote can have markup -and multiple paragraphs.
-Footnote text.
-hello
\n"); -} - -#[test] -fn doesnt_highlight_code_block_with_highlighting_off() { - let tera_ctx = Tera::default(); - let permalinks_ctx = HashMap::new(); - let mut config = Config::default_for_test(); - config.markdown.highlight_code = false; - let context = RenderContext::new( - &tera_ctx, - &config, - &config.default_language, - "", - &permalinks_ctx, - InsertAnchor::None, - ); - let res = render_content("```\n$ gutenberg server\n```", &context).unwrap(); - assert_eq!(res.body, "$ gutenberg server\n
\n");
-}
-
-#[test]
-fn can_highlight_code_block_no_lang() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap();
- assert_eq!(
- res.body,
- "$ gutenberg server\n$ ping\n
\n"
- );
-}
-
-#[test]
-fn can_highlight_code_block_with_lang() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content("```python\nlist.append(1)\n```", &context).unwrap();
- assert_eq!(
- res.body,
- "list.append(1)\n
\n"
- );
-}
-
-#[test]
-fn can_higlight_code_block_with_unknown_lang() {
- let tera_ctx = Tera::default();
- let permalinks_ctx = HashMap::new();
- let mut config = Config::default_for_test();
- config.markdown.highlight_code = true;
- let context = RenderContext::new(
- &tera_ctx,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let res = render_content("```yolo\nlist.append(1)\n```", &context).unwrap();
- // defaults to plain text
- assert_eq!(
- res.body,
- "list.append(1)\n
\n"
- );
-}
-
-#[test]
-fn can_render_shortcode() {
- let permalinks_ctx = HashMap::new();
- let config = Config::default_for_test();
- let mut context = RenderContext::new(
- &ZOLA_TERA,
- &config,
- &config.default_language,
- "",
- &permalinks_ctx,
- InsertAnchor::None,
- );
- let shortcode_def = utils::templates::get_shortcodes(&ZOLA_TERA);
- context.set_shortcode_definitions(&shortcode_def);
- let res = render_content(
- r#"
-Hello
-
-{{ youtube(id="ub36ffWAqgQ") }}
- "#,
- &context,
- )
- .unwrap();
- println!("{:?}", res.body);
- assert!(res.body.contains("Hello
\n