diff --git a/Cargo.lock b/Cargo.lock index 80028617..ee01db25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ dependencies = [ "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -39,7 +39,7 @@ dependencies = [ "cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -172,15 +172,6 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "base64" version = "0.9.3" @@ -288,9 +279,10 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "errors 0.1.0", "globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "highlighting 0.1.0", + "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", + "syntect 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -527,7 +519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "encoding_rs" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -563,6 +555,7 @@ version = "0.1.0" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntect 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -686,7 +679,7 @@ dependencies = [ [[package]] name = "futures" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -694,7 +687,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -762,7 +755,7 @@ dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -771,14 +764,6 @@ dependencies = [ "tokio-io 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "highlighting" -version = "0.1.0" -dependencies = [ - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntect 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hostname" version = "0.1.5" @@ -826,13 +811,21 @@ name = "humansize" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "humantime" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hyper" version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -857,7 +850,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.11 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -922,7 +915,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1134,7 +1127,7 @@ name = "mime" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1284,7 +1277,7 @@ dependencies = [ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1328,18 +1321,18 @@ dependencies = [ [[package]] name = "onig" -version = "3.2.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "onig_sys 68.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "onig_sys 69.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "onig_sys" -version = "68.2.1" +version = "69.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1467,12 +1460,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plist" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1607,7 +1600,6 @@ dependencies = [ "errors 0.1.0", "front_matter 0.1.0", "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "highlighting 0.1.0", "library 0.1.0", "site 0.1.0", "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1638,11 +1630,6 @@ dependencies = [ "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex-syntax" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "regex-syntax" version = "0.6.2" @@ -1666,7 +1653,6 @@ dependencies = [ "config 0.1.0", "errors 0.1.0", "front_matter 0.1.0", - "highlighting 0.1.0", "link_checker 0.1.0", "pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1674,7 +1660,7 @@ dependencies = [ "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "syntect 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntect 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "templates 0.1.0", "tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", @@ -1687,8 +1673,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.11 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1742,11 +1728,6 @@ name = "ryu" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "safemem" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "safemem" version = "0.3.0" @@ -1854,7 +1835,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2040,7 +2021,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.8" +version = "0.15.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2069,7 +2050,7 @@ dependencies = [ [[package]] name = "syntect" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2077,9 +2058,10 @@ dependencies = [ "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "onig 3.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plist 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "onig 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "plist 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2206,7 +2188,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2227,7 +2209,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2236,7 +2218,7 @@ name = "tokio-current-thread" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2245,7 +2227,7 @@ name = "tokio-executor" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2253,7 +2235,7 @@ name = "tokio-fs" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2264,7 +2246,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2274,7 +2256,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2290,7 +2272,7 @@ name = "tokio-signal" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2306,7 +2288,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2320,7 +2302,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2333,7 +2315,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2344,7 +2326,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2358,7 +2340,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2378,12 +2360,12 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2406,7 +2388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "ipconfig 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2414,7 +2396,7 @@ dependencies = [ "resolv-conf 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "trust-dns-proto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trust-dns-proto 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2481,7 +2463,7 @@ dependencies = [ [[package]] name = "unicase" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2612,7 +2594,7 @@ name = "want" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2739,7 +2721,6 @@ dependencies = [ "checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" -"checksum base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c4a342b450b268e1be8036311e2c613d7f8a7ed31214dff1cc3b60852a3168d" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2fb9e29e72fd6bc12071533d5dc7664cb01480c59406f656d7ac25c7bd8ff7" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" @@ -2780,7 +2761,7 @@ dependencies = [ "checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" -"checksum encoding_rs 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a79fa56c329a5b087de13748054fb3b974c4a672c12c71f0b66e35c5addec5" +"checksum encoding_rs 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "065f4d0c826fdaef059ac45487169d918558e3cf86c9d89f6e81cf52369126e5" "checksum error-chain 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faa976b4fd2e4c2b2f3f486874b19e61944d3de3de8b61c9fcf835d583871bcc" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" @@ -2797,7 +2778,7 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futf 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b" -"checksum futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "0c84b40c7e2de99ffd70602db314a7a8c26b2b3d830e6f7f7a142a8860ab3ca4" +"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" "checksum gif 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4bca55ac1f213920ce3527ccd62386f1f15fa3f1714aeee1cf93f2c416903f" @@ -2810,6 +2791,7 @@ dependencies = [ "checksum http 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "24f58e8c2d8e886055c3ead7b28793e1455270b5fb39650984c224bc538ba581" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum hyper 0.12.11 (registry+https://github.com/rust-lang/crates.io-index)" = "78d50abbd1790e0f4c74cb1d4a2211b439bac661d54107ad5564c55e77906762" "checksum hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32cd73f14ad370d3b4d4b7dce08f69b81536c82e39fcc89731930fe5788cd661" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -2859,8 +2841,8 @@ dependencies = [ "checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" -"checksum onig 3.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f5eeb268a4620c74ea5768c6d2ccd492d60a47a8754666b91a46bfc35cd4d1ba" -"checksum onig_sys 68.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "195ebddbb56740be48042ca117b8fb6e0d99fe392191a9362d82f5f69e510379" +"checksum onig 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0d9dac9b8a5211103d75f3ce8d0c799e6f4f3f22608eeaefb4419786e4b258" +"checksum onig_sys 69.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78c04019a39ebac42dfd8c7822af0a009043720845a812ddbb95e403298b0183" "checksum openssl 0.10.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5e2e79eede055813a3ac52fb3915caf8e1c9da2dec1587871aec9f6f7b48508d" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.36 (registry+https://github.com/rust-lang/crates.io-index)" = "409d77eeb492a1aebd6eb322b2ee72ff7c7496b4434d98b3bf8be038755de65e" @@ -2875,7 +2857,7 @@ dependencies = [ "checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b" "checksum phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b539898d22d4273ded07f64a05737649dc69095d92cb87c7097ec68e3f150b93" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum plist 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c61ac2afed2856590ae79d6f358a24b85ece246d2aa134741a66d589519b7503" +"checksum plist 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c7316832d9ac5da02786bdc89a3faf0ca07070212b388766e969078fd593edc" "checksum png 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f54b9600d584d3b8a739e1662a595fab051329eff43f20e7d8cc22872962145b" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" @@ -2894,7 +2876,6 @@ dependencies = [ "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" -"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum reqwest 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1d68c7bf0b1dc3860b80c6d31d05808bf54cdc1bfc70a4680893791becd083ae" @@ -2903,7 +2884,6 @@ dependencies = [ "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" -"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c" "checksum sass-rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90f8cf6e645aa843ffffcbdc1e8752b1f221dfa314c81895aeb229a77aea7e05" @@ -2937,10 +2917,10 @@ dependencies = [ "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.8 (registry+https://github.com/rust-lang/crates.io-index)" = "356d1c5043597c40489e9af2d2498c7fefc33e99b7d75b43be336c8a59b3e45e" +"checksum syn 0.15.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b10ee269228fb723234fce98e9aac0eaed2bd5f1ad2f6930e8d5b93f04445a1a" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" -"checksum syntect 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc8a6f0db88d4afc340522c20d260411e746b2225b257c6b238a75de9d7cec78" +"checksum syntect 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50c786fb48ac45b60657eef8af53f75ab96819fd581b6185a94839db19d9e2d7" "checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" "checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508" "checksum tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4f79f17fe555fffe4838a082a63636883ee13022888dc7bdc99edad8e0a411cd" @@ -2964,7 +2944,7 @@ dependencies = [ "checksum tokio-udp 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "da941144b816d0dcda4db3a1ba87596e4df5e860a72b70783fe435891f80601c" "checksum tokio-uds 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22e3aa6d1fcc19e635418dc0a30ab5bd65d347973d6f43f1a37bf8d9d1335fc9" "checksum toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4a2ecc31b0351ea18b3fe11274b8db6e4d82bce861bbb22e6dbed40417902c65" -"checksum trust-dns-proto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32d7c204ee231f802aa821f9dc2195aa0d0269ef7e9f8c844208565c9e3981e4" +"checksum trust-dns-proto 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35ba79f839f2ca927c2581a92286b18d4281fe3cd60984c4e48c68eb29c38793" "checksum trust-dns-resolver 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4a821ad51a29816420b8cac4b026756b81c023630b97eaa4c8090637ee3508bd" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" @@ -2975,7 +2955,7 @@ dependencies = [ "checksum unic-ucd-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48f1a08ce0409a9e391b88d1930118eec48af12742fc538bcec55f775865776e" "checksum unic-ucd-version 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1f5e6c6c53c2d0ece4a5964bc55fcff8602153063cb4fab20958ff32998ff6" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -"checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a" +"checksum unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3218ea14b4edcaccfa0df0a64a3792a2c32cc706f1b336e48867f9d3147f90" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" diff --git a/Cargo.toml b/Cargo.toml index a9ce94ff..16ff9685 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,6 @@ members = [ "components/config", "components/errors", "components/front_matter", - "components/highlighting", "components/rebuild", "components/rendering", "components/site", diff --git a/README.md b/README.md index f612f714..7acdfe04 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ You can check for any updates to the current packages by running: $ git submodule update --remote --merge ``` -And finally from the root of the components/highlighting crate run the following command: +And finally from the root of the components/config crate run the following command: ```bash $ cargo run --example generate_sublime synpack ../../sublime_syntaxes ../../sublime_syntaxes/newlines.packdump diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 457678c4..ad0f9297 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -9,6 +9,7 @@ serde = "1" serde_derive = "1" chrono = "0.4" globset = "0.4" +lazy_static = "1" +syntect = "3" errors = { path = "../errors" } -highlighting = { path = "../highlighting"} diff --git a/components/highlighting/examples/generate_sublime.rs b/components/config/examples/generate_sublime.rs similarity index 82% rename from components/highlighting/examples/generate_sublime.rs rename to components/config/examples/generate_sublime.rs index 8bf9c319..bb43c0d2 100644 --- a/components/highlighting/examples/generate_sublime.rs +++ b/components/config/examples/generate_sublime.rs @@ -3,7 +3,7 @@ //! Although it is a valid example for serializing syntaxes, you probably won't need //! to do this yourself unless you want to cache your own compiled grammars. extern crate syntect; -use syntect::parsing::SyntaxSet; +use syntect::parsing::SyntaxSetBuilder; use syntect::highlighting::ThemeSet; use syntect::dumps::*; use std::env; @@ -21,12 +21,13 @@ fn main() { let mut args = env::args().skip(1); match (args.next(), args.next(), args.next()) { (Some(ref cmd), Some(ref package_dir), Some(ref packpath_newlines)) if cmd == "synpack" => { - let mut ps = SyntaxSet::new(); - ps.load_plain_text_syntax(); - ps.load_syntaxes(package_dir, true).unwrap(); - dump_to_file(&ps, packpath_newlines).unwrap(); + let mut builder = SyntaxSetBuilder::new(); + builder.add_plain_text_syntax(); + builder.add_from_folder(package_dir, true).unwrap(); + let ss = builder.build(); + dump_to_file(&ss, packpath_newlines).unwrap(); - for s in ps.syntaxes() { + for s in ss.syntaxes() { if !s.file_extensions.is_empty() { println!("- {} -> {:?}", s.name, s.file_extensions); } diff --git a/components/config/src/config.rs b/components/config/src/config.rs new file mode 100644 index 00000000..2479cc12 --- /dev/null +++ b/components/config/src/config.rs @@ -0,0 +1,460 @@ +use std::collections::HashMap; +use std::fs::File; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; + +use chrono::Utc; +use globset::{Glob, GlobSet, GlobSetBuilder}; +use toml; +use toml::Value as Toml; +use syntect::parsing::{SyntaxSet, SyntaxSetBuilder}; + +use theme::Theme; +use highlighting::THEME_SET; +use errors::{Result, ResultExt}; + +// We want a default base url for tests +static DEFAULT_BASE_URL: &'static str = "http://a-website.com"; + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] +pub struct Taxonomy { + /// The name used in the URL, usually the plural + pub name: String, + /// If this is set, the list of individual taxonomy term page will be paginated + /// by this much + pub paginate_by: Option, + pub paginate_path: Option, + /// Whether to generate a RSS feed only for each taxonomy term, defaults to false + pub rss: bool, +} + +impl Taxonomy { + pub fn is_paginated(&self) -> bool { + if let Some(paginate_by) = self.paginate_by { + paginate_by > 0 + } else { + false + } + } +} + +impl Default for Taxonomy { + fn default() -> Taxonomy { + Taxonomy { + name: String::new(), + paginate_by: None, + paginate_path: None, + rss: false, + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(default)] +pub struct Config { + /// Base URL of the site, the only required config argument + pub base_url: String, + + /// Theme to use + pub theme: Option, + /// Title of the site. Defaults to None + pub title: Option, + /// Description of the site + pub description: Option, + + /// The language used in the site. Defaults to "en" + pub default_language: String, + /// Languages list and translated strings + pub translations: HashMap, + + /// Whether to highlight all code blocks found in markdown files. Defaults to false + pub highlight_code: bool, + /// Which themes to use for code highlighting. See Readme for supported themes + /// Defaults to "base16-ocean-dark" + pub highlight_theme: String, + + /// Whether to generate RSS. Defaults to false + pub generate_rss: bool, + /// The number of articles to include in the RSS feed. Defaults to 10_000 + pub rss_limit: usize, + + pub taxonomies: Vec, + + /// Whether to compile the `sass` directory and output the css files into the static folder + pub compile_sass: bool, + /// Whether to build the search index for the content + pub build_search_index: bool, + /// A list of file glob patterns to ignore when processing the content folder. Defaults to none. + /// Had to remove the PartialEq derive because GlobSet does not implement it. No impact + /// because it's unused anyway (who wants to sort Configs?). + pub ignored_content: Vec, + #[serde(skip_serializing, skip_deserializing)] // not a typo, 2 are needed + pub ignored_content_globset: Option, + + /// Whether to check all external links for validity + pub check_external_links: bool, + + /// A list of directories to search for additional `.sublime-syntax` files in. + pub extra_syntaxes: Vec, + /// The compiled extra syntaxes into a syntax set + #[serde(skip_serializing, skip_deserializing)] // not a typo, 2 are need + pub extra_syntax_set: Option, + + /// All user params set in [extra] in the config + pub extra: HashMap, + + /// Set automatically when instantiating the config. Used for cachebusting + pub build_timestamp: Option, +} + +impl Config { + /// Parses a string containing TOML to our Config struct + /// Any extra parameter will end up in the extra field + pub fn parse(content: &str) -> Result { + let mut config: Config = match toml::from_str(content) { + Ok(c) => c, + Err(e) => bail!(e), + }; + + if config.base_url.is_empty() || config.base_url == DEFAULT_BASE_URL { + bail!("A base URL is required in config.toml with key `base_url`"); + } + + if !THEME_SET.themes.contains_key(&config.highlight_theme) { + bail!("Highlight theme {} not available", config.highlight_theme) + } + + config.build_timestamp = Some(Utc::now().timestamp()); + + if !config.ignored_content.is_empty() { + // Convert the file glob strings into a compiled glob set matcher. We want to do this once, + // at program initialization, rather than for every page, for example. We arrange for the + // globset matcher to always exist (even though it has to be an inside an Option at the + // moment because of the TOML serializer); if the glob set is empty the `is_match` function + // of the globber always returns false. + let mut glob_set_builder = GlobSetBuilder::new(); + for pat in &config.ignored_content { + let glob = match Glob::new(pat) { + Ok(g) => g, + Err(e) => bail!( + "Invalid ignored_content glob pattern: {}, error = {}", + pat, + e + ), + }; + glob_set_builder.add(glob); + } + config.ignored_content_globset = Some( + glob_set_builder + .build() + .expect("Bad ignored_content in config file."), + ); + } + + Ok(config) + } + + /// Parses a config file from the given path + pub fn from_file>(path: P) -> Result { + let mut content = String::new(); + let path = path.as_ref(); + let file_name = path.file_name().unwrap(); + File::open(path) + .chain_err(|| { + format!( + "No `{:?}` file found. Are you in the right directory?", + file_name + ) + })? + .read_to_string(&mut content)?; + + Config::parse(&content) + } + + /// Attempt to load any extra syntax found in the extra syntaxes of the config + pub fn load_extra_syntaxes(&mut self, base_path: &Path) -> Result<()> { + if self.extra_syntaxes.is_empty() { + return Ok(()); + } + + let mut ss = SyntaxSetBuilder::new(); + for dir in &self.extra_syntaxes { + ss.add_from_folder(base_path.join(dir), true)?; + } + self.extra_syntax_set = Some(ss.build()); + + Ok(()) + } + + /// Makes a url, taking into account that the base url might have a trailing slash + pub fn make_permalink(&self, path: &str) -> String { + let trailing_bit = if path.ends_with('/') || path.is_empty() { + "" + } else { + "/" + }; + + // Index section with a base url that has a trailing slash + if self.base_url.ends_with('/') && path == "/" { + self.base_url.clone() + } else if path == "/" { + // index section with a base url that doesn't have a trailing slash + format!("{}/", self.base_url) + } else if self.base_url.ends_with('/') && path.starts_with('/') { + format!("{}{}{}", self.base_url, &path[1..], trailing_bit) + } else if self.base_url.ends_with('/') || path.starts_with('/') { + format!("{}{}{}", self.base_url, path, trailing_bit) + } else { + format!("{}/{}{}", self.base_url, path, trailing_bit) + } + } + + /// Merges the extra data from the theme with the config extra data + fn add_theme_extra(&mut self, theme: &Theme) -> Result<()> { + // 3 pass merging + // 1. save config to preserve user + let original = self.extra.clone(); + // 2. inject theme extra values + for (key, val) in &theme.extra { + self.extra + .entry(key.to_string()) + .or_insert_with(|| val.clone()); + } + + // 3. overwrite with original config + for (key, val) in &original { + self.extra + .entry(key.to_string()) + .or_insert_with(|| val.clone()); + } + + Ok(()) + } + + /// Parse the theme.toml file and merges the extra data from the theme + /// with the config extra data + pub fn merge_with_theme(&mut self, path: &PathBuf) -> Result<()> { + let theme = Theme::from_file(path)?; + self.add_theme_extra(&theme) + } +} + +impl Default for Config { + fn default() -> Config { + Config { + base_url: DEFAULT_BASE_URL.to_string(), + title: None, + description: None, + theme: None, + highlight_code: false, + highlight_theme: "base16-ocean-dark".to_string(), + default_language: "en".to_string(), + generate_rss: false, + rss_limit: 10_000, + taxonomies: Vec::new(), + compile_sass: false, + check_external_links: false, + build_search_index: false, + ignored_content: Vec::new(), + ignored_content_globset: None, + translations: HashMap::new(), + extra_syntaxes: Vec::new(), + extra_syntax_set: None, + extra: HashMap::new(), + build_timestamp: Some(1), + } + } +} + +#[cfg(test)] +mod tests { + use super::{Config, Theme}; + + #[test] + fn can_import_valid_config() { + let config = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com" + "#; + + let config = Config::parse(config).unwrap(); + assert_eq!(config.title.unwrap(), "My site".to_string()); + } + + #[test] + fn errors_when_invalid_type() { + let config = r#" +title = 1 +base_url = "https://replace-this-with-your-url.com" + "#; + + let config = Config::parse(config); + assert!(config.is_err()); + } + + #[test] + fn errors_when_missing_required_field() { + // base_url is required + let config = r#" +title = "" + "#; + + let config = Config::parse(config); + assert!(config.is_err()); + } + + #[test] + fn can_add_extra_values() { + let config = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com" + +[extra] +hello = "world" + "#; + + let config = Config::parse(config); + assert!(config.is_ok()); + assert_eq!( + config + .unwrap() + .extra + .get("hello") + .unwrap() + .as_str() + .unwrap(), + "world" + ); + } + + #[test] + fn can_make_url_index_page_with_non_trailing_slash_url() { + let mut config = Config::default(); + config.base_url = "http://vincent.is".to_string(); + assert_eq!(config.make_permalink(""), "http://vincent.is/"); + } + + #[test] + fn can_make_url_index_page_with_railing_slash_url() { + let mut config = Config::default(); + config.base_url = "http://vincent.is/".to_string(); + assert_eq!(config.make_permalink(""), "http://vincent.is/"); + } + + #[test] + fn can_make_url_with_non_trailing_slash_base_url() { + let mut config = Config::default(); + config.base_url = "http://vincent.is".to_string(); + assert_eq!(config.make_permalink("hello"), "http://vincent.is/hello/"); + } + + #[test] + fn can_make_url_with_trailing_slash_path() { + let mut config = Config::default(); + config.base_url = "http://vincent.is/".to_string(); + assert_eq!(config.make_permalink("/hello"), "http://vincent.is/hello/"); + } + + #[test] + fn can_make_url_with_localhost() { + let mut config = Config::default(); + config.base_url = "http://127.0.0.1:1111".to_string(); + assert_eq!( + config.make_permalink("/tags/rust"), + "http://127.0.0.1:1111/tags/rust/" + ); + } + + #[test] + fn can_merge_with_theme_data_and_preserve_config_value() { + let config_str = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com" + +[extra] +hello = "world" + "#; + let mut config = Config::parse(config_str).unwrap(); + let theme_str = r#" +[extra] +hello = "foo" +a_value = 10 + "#; + let theme = Theme::parse(theme_str).unwrap(); + assert!(config.add_theme_extra(&theme).is_ok()); + let extra = config.extra; + assert_eq!(extra["hello"].as_str().unwrap(), "world".to_string()); + assert_eq!(extra["a_value"].as_integer().unwrap(), 10); + } + + #[test] + fn can_use_language_configuration() { + let config = r#" +base_url = "https://remplace-par-ton-url.fr" +default_language = "fr" + +[translations] +[translations.fr] +title = "Un titre" + +[translations.en] +title = "A title" + + "#; + + let config = Config::parse(config); + assert!(config.is_ok()); + let translations = config.unwrap().translations; + assert_eq!(translations["fr"]["title"].as_str().unwrap(), "Un titre"); + assert_eq!(translations["en"]["title"].as_str().unwrap(), "A title"); + } + + #[test] + fn missing_ignored_content_results_in_empty_vector_and_empty_globset() { + let config_str = r#" +title = "My site" +base_url = "example.com" + "#; + + let config = Config::parse(config_str).unwrap(); + let v = config.ignored_content; + assert_eq!(v.len(), 0); + assert!(config.ignored_content_globset.is_none()); + } + + #[test] + fn empty_ignored_content_results_in_empty_vector_and_empty_globset() { + let config_str = r#" +title = "My site" +base_url = "example.com" +ignored_content = [] + "#; + + let config = Config::parse(config_str).unwrap(); + assert_eq!(config.ignored_content.len(), 0); + assert!(config.ignored_content_globset.is_none()); + } + + #[test] + fn non_empty_ignored_content_results_in_vector_of_patterns_and_configured_globset() { + let config_str = r#" +title = "My site" +base_url = "example.com" +ignored_content = ["*.{graphml,iso}", "*.py?"] + "#; + + let config = Config::parse(config_str).unwrap(); + let v = config.ignored_content; + assert_eq!(v, vec!["*.{graphml,iso}", "*.py?"]); + + let g = config.ignored_content_globset.unwrap(); + assert_eq!(g.len(), 2); + assert!(g.is_match("foo.graphml")); + assert!(g.is_match("foo.iso")); + assert!(!g.is_match("foo.png")); + assert!(g.is_match("foo.py2")); + assert!(g.is_match("foo.py3")); + assert!(!g.is_match("foo.py")); + } +} diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs new file mode 100644 index 00000000..0c35d812 --- /dev/null +++ b/components/config/src/highlighting.rs @@ -0,0 +1,41 @@ +use syntect::dumps::from_binary; +use syntect::parsing::SyntaxSet; +use syntect::highlighting::ThemeSet; +use syntect::easy::HighlightLines; + +use Config; + + +lazy_static! { + pub static ref SYNTAX_SET: SyntaxSet = { + let ss: SyntaxSet = from_binary(include_bytes!("../../../sublime_syntaxes/newlines.packdump")); + ss + }; + + pub static ref THEME_SET: ThemeSet = from_binary(include_bytes!("../../../sublime_themes/all.themedump")); +} + +/// Returns the highlighter and whether it was found in the extra or not +pub fn get_highlighter<'a>(info: &str, config: &Config) -> (HighlightLines<'a>, bool) { + let theme = &THEME_SET.themes[&config.highlight_theme]; + let mut in_extra = false; + + if let Some(ref lang) = info.split(' ').next() { + let syntax = SYNTAX_SET.find_syntax_by_token(lang) + .or_else(|| { + if let Some(ref extra) = config.extra_syntax_set { + let s = extra.find_syntax_by_token(lang); + if s.is_some() { + in_extra = true; + } + s + } else { + None + } + }) + .unwrap_or_else(|| SYNTAX_SET.find_syntax_plain_text()); + (HighlightLines::new(syntax, theme), in_extra) + } else { + (HighlightLines::new(SYNTAX_SET.find_syntax_plain_text(), theme), false) + } +} diff --git a/components/config/src/lib.rs b/components/config/src/lib.rs index 0aa884ef..52bd813e 100644 --- a/components/config/src/lib.rs +++ b/components/config/src/lib.rs @@ -5,258 +5,17 @@ extern crate toml; extern crate errors; extern crate chrono; extern crate globset; -extern crate highlighting; +#[macro_use] +extern crate lazy_static; +extern crate syntect; -use std::collections::HashMap; -use std::fs::File; -use std::io::prelude::*; -use std::path::{Path, PathBuf}; - -use chrono::Utc; -use globset::{Glob, GlobSet, GlobSetBuilder}; -use toml::Value as Toml; - -use errors::{Result, ResultExt}; -use highlighting::THEME_SET; +mod config; mod theme; +pub mod highlighting; +pub use config::{Config, Taxonomy}; -use theme::Theme; - -// We want a default base url for tests -static DEFAULT_BASE_URL: &'static str = "http://a-website.com"; - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(default)] -pub struct Taxonomy { - /// The name used in the URL, usually the plural - pub name: String, - /// If this is set, the list of individual taxonomy term page will be paginated - /// by this much - pub paginate_by: Option, - pub paginate_path: Option, - /// Whether to generate a RSS feed only for each taxonomy term, defaults to false - pub rss: bool, -} - -impl Taxonomy { - pub fn is_paginated(&self) -> bool { - if let Some(paginate_by) = self.paginate_by { - paginate_by > 0 - } else { - false - } - } -} - -impl Default for Taxonomy { - fn default() -> Taxonomy { - Taxonomy { - name: String::new(), - paginate_by: None, - paginate_path: None, - rss: false, - } - } -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(default)] -pub struct Config { - /// Base URL of the site, the only required config argument - pub base_url: String, - - /// Theme to use - pub theme: Option, - /// Title of the site. Defaults to None - pub title: Option, - /// Description of the site - pub description: Option, - - /// The language used in the site. Defaults to "en" - pub default_language: String, - /// Languages list and translated strings - pub translations: HashMap, - - /// Whether to highlight all code blocks found in markdown files. Defaults to false - pub highlight_code: bool, - /// Which themes to use for code highlighting. See Readme for supported themes - /// Defaults to "base16-ocean-dark" - pub highlight_theme: String, - - /// Whether to generate RSS. Defaults to false - pub generate_rss: bool, - /// The number of articles to include in the RSS feed. Defaults to 10_000 - pub rss_limit: usize, - - pub taxonomies: Vec, - - /// Whether to compile the `sass` directory and output the css files into the static folder - pub compile_sass: bool, - /// Whether to build the search index for the content - pub build_search_index: bool, - /// A list of file glob patterns to ignore when processing the content folder. Defaults to none. - /// Had to remove the PartialEq derive because GlobSet does not implement it. No impact - /// because it's unused anyway (who wants to sort Configs?). - pub ignored_content: Vec, - #[serde(skip_serializing, skip_deserializing)] // not a typo, 2 are needed - pub ignored_content_globset: Option, - - /// Whether to check all external links for validity - pub check_external_links: bool, - - /// A list of directories to search for additional `.sublime-syntax` files in. - pub extra_syntaxes: Vec, - - /// All user params set in [extra] in the config - pub extra: HashMap, - - /// Set automatically when instantiating the config. Used for cachebusting - pub build_timestamp: Option, -} - -impl Config { - /// Parses a string containing TOML to our Config struct - /// Any extra parameter will end up in the extra field - pub fn parse(content: &str) -> Result { - let mut config: Config = match toml::from_str(content) { - Ok(c) => c, - Err(e) => bail!(e), - }; - - if config.base_url.is_empty() || config.base_url == DEFAULT_BASE_URL { - bail!("A base URL is required in config.toml with key `base_url`"); - } - - if !THEME_SET.themes.contains_key(&config.highlight_theme) { - bail!("Highlight theme {} not available", config.highlight_theme) - } - - config.build_timestamp = Some(Utc::now().timestamp()); - - if !config.ignored_content.is_empty() { - // Convert the file glob strings into a compiled glob set matcher. We want to do this once, - // at program initialization, rather than for every page, for example. We arrange for the - // globset matcher to always exist (even though it has to be an inside an Option at the - // moment because of the TOML serializer); if the glob set is empty the `is_match` function - // of the globber always returns false. - let mut glob_set_builder = GlobSetBuilder::new(); - for pat in &config.ignored_content { - let glob = match Glob::new(pat) { - Ok(g) => g, - Err(e) => bail!( - "Invalid ignored_content glob pattern: {}, error = {}", - pat, - e - ), - }; - glob_set_builder.add(glob); - } - config.ignored_content_globset = Some( - glob_set_builder - .build() - .expect("Bad ignored_content in config file."), - ); - } - - Ok(config) - } - - /// Parses a config file from the given path - pub fn from_file>(path: P) -> Result { - let mut content = String::new(); - let path = path.as_ref(); - let file_name = path.file_name().unwrap(); - File::open(path) - .chain_err(|| { - format!( - "No `{:?}` file found. Are you in the right directory?", - file_name - ) - })? - .read_to_string(&mut content)?; - - Config::parse(&content) - } - - /// Makes a url, taking into account that the base url might have a trailing slash - pub fn make_permalink(&self, path: &str) -> String { - let trailing_bit = if path.ends_with('/') || path.is_empty() { - "" - } else { - "/" - }; - - // Index section with a base url that has a trailing slash - if self.base_url.ends_with('/') && path == "/" { - self.base_url.clone() - } else if path == "/" { - // index section with a base url that doesn't have a trailing slash - format!("{}/", self.base_url) - } else if self.base_url.ends_with('/') && path.starts_with('/') { - format!("{}{}{}", self.base_url, &path[1..], trailing_bit) - } else if self.base_url.ends_with('/') || path.starts_with('/') { - format!("{}{}{}", self.base_url, path, trailing_bit) - } else { - format!("{}/{}{}", self.base_url, path, trailing_bit) - } - } - - /// Merges the extra data from the theme with the config extra data - fn add_theme_extra(&mut self, theme: &Theme) -> Result<()> { - // 3 pass merging - // 1. save config to preserve user - let original = self.extra.clone(); - // 2. inject theme extra values - for (key, val) in &theme.extra { - self.extra - .entry(key.to_string()) - .or_insert_with(|| val.clone()); - } - - // 3. overwrite with original config - for (key, val) in &original { - self.extra - .entry(key.to_string()) - .or_insert_with(|| val.clone()); - } - - Ok(()) - } - - /// Parse the theme.toml file and merges the extra data from the theme - /// with the config extra data - pub fn merge_with_theme(&mut self, path: &PathBuf) -> Result<()> { - let theme = Theme::from_file(path)?; - self.add_theme_extra(&theme) - } -} - -impl Default for Config { - fn default() -> Config { - Config { - base_url: DEFAULT_BASE_URL.to_string(), - title: None, - description: None, - theme: None, - highlight_code: false, - highlight_theme: "base16-ocean-dark".to_string(), - default_language: "en".to_string(), - generate_rss: false, - rss_limit: 10_000, - taxonomies: Vec::new(), - compile_sass: false, - check_external_links: false, - build_search_index: false, - ignored_content: Vec::new(), - ignored_content_globset: None, - translations: HashMap::new(), - extra_syntaxes: Vec::new(), - extra: HashMap::new(), - build_timestamp: Some(1), - } - } -} +use std::path::Path; /// Get and parse the config. /// If it doesn't succeed, exit @@ -270,195 +29,3 @@ pub fn get_config(path: &Path, filename: &str) -> Config { } } } - -#[cfg(test)] -mod tests { - use super::{Config, Theme}; - - #[test] - fn can_import_valid_config() { - let config = r#" -title = "My site" -base_url = "https://replace-this-with-your-url.com" - "#; - - let config = Config::parse(config).unwrap(); - assert_eq!(config.title.unwrap(), "My site".to_string()); - } - - #[test] - fn errors_when_invalid_type() { - let config = r#" -title = 1 -base_url = "https://replace-this-with-your-url.com" - "#; - - let config = Config::parse(config); - assert!(config.is_err()); - } - - #[test] - fn errors_when_missing_required_field() { - // base_url is required - let config = r#" -title = "" - "#; - - let config = Config::parse(config); - assert!(config.is_err()); - } - - #[test] - fn can_add_extra_values() { - let config = r#" -title = "My site" -base_url = "https://replace-this-with-your-url.com" - -[extra] -hello = "world" - "#; - - let config = Config::parse(config); - assert!(config.is_ok()); - assert_eq!( - config - .unwrap() - .extra - .get("hello") - .unwrap() - .as_str() - .unwrap(), - "world" - ); - } - - #[test] - fn can_make_url_index_page_with_non_trailing_slash_url() { - let mut config = Config::default(); - config.base_url = "http://vincent.is".to_string(); - assert_eq!(config.make_permalink(""), "http://vincent.is/"); - } - - #[test] - fn can_make_url_index_page_with_railing_slash_url() { - let mut config = Config::default(); - config.base_url = "http://vincent.is/".to_string(); - assert_eq!(config.make_permalink(""), "http://vincent.is/"); - } - - #[test] - fn can_make_url_with_non_trailing_slash_base_url() { - let mut config = Config::default(); - config.base_url = "http://vincent.is".to_string(); - assert_eq!(config.make_permalink("hello"), "http://vincent.is/hello/"); - } - - #[test] - fn can_make_url_with_trailing_slash_path() { - let mut config = Config::default(); - config.base_url = "http://vincent.is/".to_string(); - assert_eq!(config.make_permalink("/hello"), "http://vincent.is/hello/"); - } - - #[test] - fn can_make_url_with_localhost() { - let mut config = Config::default(); - config.base_url = "http://127.0.0.1:1111".to_string(); - assert_eq!( - config.make_permalink("/tags/rust"), - "http://127.0.0.1:1111/tags/rust/" - ); - } - - #[test] - fn can_merge_with_theme_data_and_preserve_config_value() { - let config_str = r#" -title = "My site" -base_url = "https://replace-this-with-your-url.com" - -[extra] -hello = "world" - "#; - let mut config = Config::parse(config_str).unwrap(); - let theme_str = r#" -[extra] -hello = "foo" -a_value = 10 - "#; - let theme = Theme::parse(theme_str).unwrap(); - assert!(config.add_theme_extra(&theme).is_ok()); - let extra = config.extra; - assert_eq!(extra["hello"].as_str().unwrap(), "world".to_string()); - assert_eq!(extra["a_value"].as_integer().unwrap(), 10); - } - - #[test] - fn can_use_language_configuration() { - let config = r#" -base_url = "https://remplace-par-ton-url.fr" -default_language = "fr" - -[translations] -[translations.fr] -title = "Un titre" - -[translations.en] -title = "A title" - - "#; - - let config = Config::parse(config); - assert!(config.is_ok()); - let translations = config.unwrap().translations; - assert_eq!(translations["fr"]["title"].as_str().unwrap(), "Un titre"); - assert_eq!(translations["en"]["title"].as_str().unwrap(), "A title"); - } - - #[test] - fn missing_ignored_content_results_in_empty_vector_and_empty_globset() { - let config_str = r#" -title = "My site" -base_url = "example.com" - "#; - - let config = Config::parse(config_str).unwrap(); - let v = config.ignored_content; - assert_eq!(v.len(), 0); - assert!(config.ignored_content_globset.is_none()); - } - - #[test] - fn empty_ignored_content_results_in_empty_vector_and_empty_globset() { - let config_str = r#" -title = "My site" -base_url = "example.com" -ignored_content = [] - "#; - - let config = Config::parse(config_str).unwrap(); - assert_eq!(config.ignored_content.len(), 0); - assert!(config.ignored_content_globset.is_none()); - } - - #[test] - fn non_empty_ignored_content_results_in_vector_of_patterns_and_configured_globset() { - let config_str = r#" -title = "My site" -base_url = "example.com" -ignored_content = ["*.{graphml,iso}", "*.py?"] - "#; - - let config = Config::parse(config_str).unwrap(); - let v = config.ignored_content; - assert_eq!(v, vec!["*.{graphml,iso}", "*.py?"]); - - let g = config.ignored_content_globset.unwrap(); - assert_eq!(g.len(), 2); - assert!(g.is_match("foo.graphml")); - assert!(g.is_match("foo.iso")); - assert!(!g.is_match("foo.png")); - assert!(g.is_match("foo.py2")); - assert!(g.is_match("foo.py3")); - assert!(!g.is_match("foo.py")); - } -} diff --git a/components/errors/Cargo.toml b/components/errors/Cargo.toml index fdf6bb20..eacf9168 100644 --- a/components/errors/Cargo.toml +++ b/components/errors/Cargo.toml @@ -8,3 +8,4 @@ error-chain = "0.12" tera = "0.11" toml = "0.4" image = "0.20" +syntect = "3" diff --git a/components/errors/src/lib.rs b/components/errors/src/lib.rs index 9bc146f1..4471651a 100755 --- a/components/errors/src/lib.rs +++ b/components/errors/src/lib.rs @@ -5,6 +5,7 @@ extern crate error_chain; extern crate tera; extern crate toml; extern crate image; +extern crate syntect; error_chain! { errors {} @@ -17,6 +18,7 @@ error_chain! { Io(::std::io::Error); Toml(toml::de::Error); Image(image::ImageError); + Syntect(syntect::LoadingError); } } diff --git a/components/highlighting/Cargo.toml b/components/highlighting/Cargo.toml deleted file mode 100644 index b2fed89a..00000000 --- a/components/highlighting/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "highlighting" -version = "0.1.0" -authors = ["Vincent Prouillet "] - -[dependencies] -lazy_static = "1" -syntect = "2" diff --git a/components/highlighting/src/lib.rs b/components/highlighting/src/lib.rs deleted file mode 100644 index 34f0c1cc..00000000 --- a/components/highlighting/src/lib.rs +++ /dev/null @@ -1,44 +0,0 @@ -#[macro_use] -extern crate lazy_static; -extern crate syntect; - -use std::cell::RefCell; -use std::path::Path; - -use syntect::LoadingError; -use syntect::dumps::from_binary; -use syntect::parsing::SyntaxSet; -use syntect::highlighting::{ThemeSet, Theme}; -use syntect::easy::HighlightLines; - -thread_local! { - /// A pair of the set and whether extras have been added to it. - pub static SYNTAX_SET: RefCell<(SyntaxSet, bool)> = { - let ss: SyntaxSet = from_binary(include_bytes!("../../../sublime_syntaxes/newlines.packdump")); - RefCell::new((ss, false)) - }; -} - -lazy_static! { - pub static ref THEME_SET: ThemeSet = from_binary(include_bytes!("../../../sublime_themes/all.themedump")); -} - -pub fn get_highlighter<'a>(theme: &'a Theme, info: &str, base_path: &Path, extra_syntaxes: &[String]) -> Result, LoadingError> { - SYNTAX_SET.with(|rc| { - let (ss, extras_added) = &mut *rc.borrow_mut(); - if !*extras_added { - for dir in extra_syntaxes { - ss.load_syntaxes(base_path.join(dir), true)?; - } - ss.link_syntaxes(); - *extras_added = true; - } - - let syntax = info - .split(' ') - .next() - .and_then(|lang| ss.find_syntax_by_token(lang)) - .unwrap_or_else(|| ss.find_syntax_plain_text()); - Ok(HighlightLines::new(syntax, theme)) - }) -} diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index b7b47eaa..085c2fd4 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -287,7 +287,6 @@ impl Page { permalinks: &HashMap, tera: &Tera, config: &Config, - base_path: &Path, anchor_insert: InsertAnchor, ) -> Result<()> { let mut context = RenderContext::new( @@ -295,7 +294,6 @@ impl Page { config, &self.permalink, permalinks, - base_path, anchor_insert, ); @@ -402,7 +400,6 @@ Hello world"#; &HashMap::default(), &Tera::default(), &Config::default(), - Path::new("something"), InsertAnchor::None, ).unwrap(); @@ -514,7 +511,6 @@ Hello world &HashMap::default(), &Tera::default(), &config, - Path::new("something"), InsertAnchor::None, ).unwrap(); assert_eq!(page.summary, Some("

Hello world

\n".to_string())); diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index de4df12d..79104228 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -205,14 +205,12 @@ impl Section { permalinks: &HashMap, tera: &Tera, config: &Config, - base_path: &Path, ) -> Result<()> { let mut context = RenderContext::new( tera, config, &self.permalink, permalinks, - base_path, self.meta.insert_anchor_links, ); diff --git a/components/rebuild/Cargo.toml b/components/rebuild/Cargo.toml index 7277e9c3..358f7b5d 100644 --- a/components/rebuild/Cargo.toml +++ b/components/rebuild/Cargo.toml @@ -6,7 +6,6 @@ authors = ["Vincent Prouillet "] [dependencies] errors = { path = "../errors" } front_matter = { path = "../front_matter" } -highlighting = { path = "../highlighting" } library = { path = "../library" } site = { path = "../site" } diff --git a/components/rendering/Cargo.toml b/components/rendering/Cargo.toml index 22a6e6fa..e39734ad 100644 --- a/components/rendering/Cargo.toml +++ b/components/rendering/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Vincent Prouillet "] [dependencies] tera = { version = "0.11", features = ["preserve_order"] } -syntect = "2" +syntect = "3" pulldown-cmark = "0" slug = "0.1" serde = "1" @@ -15,7 +15,6 @@ pest_derive = "1" errors = { path = "../errors" } front_matter = { path = "../front_matter" } -highlighting = { path = "../highlighting"} utils = { path = "../utils" } config = { path = "../config" } link_checker = { path = "../link_checker" } diff --git a/components/rendering/src/context.rs b/components/rendering/src/context.rs index b4bd24c2..68bc215b 100644 --- a/components/rendering/src/context.rs +++ b/components/rendering/src/context.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::path::Path; use tera::{Tera, Context}; use front_matter::InsertAnchor; @@ -14,7 +13,6 @@ pub struct RenderContext<'a> { pub tera_context: Context, pub current_page_permalink: &'a str, pub permalinks: &'a HashMap, - pub base_path: &'a Path, pub insert_anchor: InsertAnchor, } @@ -24,7 +22,6 @@ impl<'a> RenderContext<'a> { config: &'a Config, current_page_permalink: &'a str, permalinks: &'a HashMap, - base_path: &'a Path, insert_anchor: InsertAnchor, ) -> RenderContext<'a> { let mut tera_context = Context::new(); @@ -35,7 +32,6 @@ impl<'a> RenderContext<'a> { current_page_permalink, permalinks, insert_anchor, - base_path, config, } } diff --git a/components/rendering/src/lib.rs b/components/rendering/src/lib.rs index acc08953..d9dc12dc 100644 --- a/components/rendering/src/lib.rs +++ b/components/rendering/src/lib.rs @@ -12,7 +12,6 @@ extern crate pest_derive; #[macro_use] extern crate errors; extern crate front_matter; -extern crate highlighting; extern crate utils; extern crate config; extern crate link_checker; diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index 63d45eb4..e4af6fa5 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -4,11 +4,11 @@ use pulldown_cmark as cmark; use self::cmark::{Parser, Event, Tag, Options, OPTION_ENABLE_TABLES, OPTION_ENABLE_FOOTNOTES}; use slug::slugify; use syntect::easy::HighlightLines; -use syntect::html::{start_coloured_html_snippet, styles_to_coloured_html, IncludeBackground}; +use syntect::html::{start_highlighted_html_snippet, styled_line_to_highlighted_html, IncludeBackground}; use errors::Result; use utils::site::resolve_internal_link; -use highlighting::{get_highlighter, THEME_SET}; +use config::highlighting::{get_highlighter, THEME_SET, SYNTAX_SET}; use link_checker::check_url; use table_of_contents::{TempHeader, Header, make_table_of_contents}; @@ -52,7 +52,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result = None; + let mut highlighter: Option<(HighlightLines, bool)> = None; // If we get text in header, we need to insert the id and a anchor let mut in_header = false; // pulldown_cmark can send several text events for a title if there are markdown @@ -92,9 +92,18 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result Result { - highlighter = Some(h); - // This selects the background color the same way that start_coloured_html_snippet does - let color = theme.settings.background.unwrap_or(::syntect::highlighting::Color::WHITE); - background = IncludeBackground::IfDifferent(color); - } - Err(err) => { - error = Some(format!("Could not load syntax: {}", err).into()); - return Event::Html(Borrowed("")); - } - } - let snippet = start_coloured_html_snippet(theme); - Event::Html(Owned(snippet)) + highlighter = Some(get_highlighter(info, &context.config)); + // This selects the background color the same way that start_coloured_html_snippet does + let color = theme.settings.background.unwrap_or(::syntect::highlighting::Color::WHITE); + background = IncludeBackground::IfDifferent(color); + let snippet = start_highlighted_html_snippet(theme); + Event::Html(Owned(snippet.0)) } Event::End(Tag::CodeBlock(_)) => { if !context.config.highlight_code { diff --git a/components/rendering/src/shortcode.rs b/components/rendering/src/shortcode.rs index f6dc848b..67debc29 100644 --- a/components/rendering/src/shortcode.rs +++ b/components/rendering/src/shortcode.rs @@ -180,7 +180,6 @@ pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result String { let config = Config::default(); let permalinks = HashMap::new(); - let context = RenderContext::new(&tera, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks, InsertAnchor::None); super::render_shortcodes(code, &context).unwrap() } diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index c9309130..b4894ddb 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -5,7 +5,6 @@ extern crate rendering; extern crate config; use std::collections::HashMap; -use std::path::Path; use tera::Tera; @@ -20,7 +19,7 @@ fn can_do_render_content_simple() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("hello", &context).unwrap(); assert_eq!(res.body, "

hello

\n"); } @@ -31,7 +30,7 @@ fn doesnt_highlight_code_block_with_highlighting_off() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.highlight_code = false; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("```\n$ gutenberg server\n```", &context).unwrap(); assert_eq!( res.body, @@ -45,11 +44,11 @@ fn can_highlight_code_block_no_lang() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap(); assert_eq!( res.body, - "
\n$ gutenberg server\n$ ping\n
" + "
\n$ gutenberg server\n$ ping\n
" ); } @@ -59,11 +58,11 @@ fn can_highlight_code_block_with_lang() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("```python\nlist.append(1)\n```", &context).unwrap(); assert_eq!( res.body, - "
\nlist.append(1)\n
" + "
\nlist.append(1)\n
" ); } @@ -73,12 +72,12 @@ fn can_higlight_code_block_with_unknown_lang() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("```yolo\nlist.append(1)\n```", &context).unwrap(); // defaults to plain text assert_eq!( res.body, - "
\nlist.append(1)\n
" + "
\nlist.append(1)\n
" ); } @@ -86,7 +85,7 @@ fn can_higlight_code_block_with_unknown_lang() { fn can_render_shortcode() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(r#" Hello @@ -100,7 +99,7 @@ Hello fn can_render_shortcode_with_markdown_char_in_args_name() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let input = vec![ "name", "na_me", @@ -117,7 +116,7 @@ fn can_render_shortcode_with_markdown_char_in_args_name() { fn can_render_shortcode_with_markdown_char_in_args_value() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let input = vec![ "ub36ffWAqgQ-hey", "ub36ffWAqgQ_hey", @@ -144,7 +143,7 @@ fn can_render_body_shortcode_with_markdown_char_in_name() { for i in input { tera.add_raw_template(&format!("shortcodes/{}.html", i), "
{{ body }} - {{ author}}
").unwrap(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(&format!("{{% {}(author=\"Bob\") %}}\nhey\n{{% end %}}", i), &context).unwrap(); println!("{:?}", res); @@ -173,7 +172,7 @@ Here is another paragraph. tera.add_raw_template(&format!("shortcodes/{}.html", "figure"), shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(markdown_string, &context).unwrap(); println!("{:?}", res); @@ -206,7 +205,7 @@ Here is another paragraph. tera.add_raw_template(&format!("shortcodes/{}.html", "figure"), shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(markdown_string, &context).unwrap(); println!("{:?}", res); @@ -217,7 +216,7 @@ Here is another paragraph. fn can_render_several_shortcode_in_row() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(r#" Hello @@ -244,7 +243,7 @@ fn doesnt_render_ignored_shortcodes() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.highlight_code = false; - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(r#"```{{/* youtube(id="w7Ft2ymGmfc") */}}```"#, &context).unwrap(); assert_eq!(res.body, "

{{ youtube(id="w7Ft2ymGmfc") }}

\n"); } @@ -256,7 +255,7 @@ fn can_render_shortcode_with_body() { tera.add_raw_template("shortcodes/quote.html", "
{{ body }} - {{ author }}
").unwrap(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(r#" Hello @@ -272,7 +271,7 @@ fn errors_rendering_unknown_shortcode() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("{{ hello(flash=true) }}", &context); assert!(res.is_err()); } @@ -283,7 +282,7 @@ fn can_make_valid_relative_link() { permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about".to_string()); let tera_ctx = Tera::default(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); let res = render_content( r#"[rel link](./pages/about.md), [abs link](https://vincent.is/about)"#, &context, @@ -300,7 +299,7 @@ fn can_make_relative_links_with_anchors() { permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about".to_string()); let tera_ctx = Tera::default(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); let res = render_content(r#"[rel link](./pages/about.md#cv)"#, &context).unwrap(); assert!( @@ -313,7 +312,7 @@ fn errors_relative_link_inexistant() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("[rel link](./pages/about.md)", &context); assert!(res.is_err()); } @@ -323,7 +322,7 @@ fn can_add_id_to_headers() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content(r#"# Hello"#, &context).unwrap(); assert_eq!(res.body, "

Hello

\n"); } @@ -333,7 +332,7 @@ fn can_add_id_to_headers_same_slug() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("# Hello\n# Hello", &context).unwrap(); assert_eq!(res.body, "

Hello

\n

Hello

\n"); } @@ -342,7 +341,7 @@ fn can_add_id_to_headers_same_slug() { fn can_insert_anchor_left() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); let res = render_content("# Hello", &context).unwrap(); assert_eq!( res.body, @@ -354,7 +353,7 @@ fn can_insert_anchor_left() { fn can_insert_anchor_right() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Right); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Right); let res = render_content("# Hello", &context).unwrap(); assert_eq!( res.body, @@ -367,7 +366,7 @@ fn can_insert_anchor_right() { fn can_insert_anchor_with_exclamation_mark() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); let res = render_content("# Hello!", &context).unwrap(); assert_eq!( res.body, @@ -380,7 +379,7 @@ fn can_insert_anchor_with_exclamation_mark() { fn can_insert_anchor_with_link() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); let res = render_content("## [Rust](https://rust-lang.org)", &context).unwrap(); assert_eq!( res.body, @@ -392,7 +391,7 @@ fn can_insert_anchor_with_link() { fn can_insert_anchor_with_other_special_chars() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); let res = render_content("# Hello*_()", &context).unwrap(); assert_eq!( res.body, @@ -409,7 +408,6 @@ fn can_make_toc() { &config, "https://mysite.com/something", &permalinks_ctx, - Path::new("something"), InsertAnchor::Left, ); @@ -433,7 +431,7 @@ fn can_make_toc() { fn can_understand_backtick_in_titles() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("# `Hello`", &context).unwrap(); assert_eq!( res.body, @@ -445,7 +443,7 @@ fn can_understand_backtick_in_titles() { fn can_understand_backtick_in_paragraphs() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("Hello `world`", &context).unwrap(); assert_eq!( res.body, @@ -458,7 +456,7 @@ fn can_understand_backtick_in_paragraphs() { fn can_understand_links_in_header() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("# [Rust](https://rust-lang.org)", &context).unwrap(); assert_eq!( res.body, @@ -470,7 +468,7 @@ fn can_understand_links_in_header() { fn can_understand_link_with_title_in_header() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("# [Rust](https://rust-lang.org \"Rust homepage\")", &context).unwrap(); assert_eq!( res.body, @@ -484,7 +482,7 @@ fn can_make_valid_relative_link_in_header() { permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about/".to_string()); let tera_ctx = Tera::default(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); let res = render_content( r#" # [rel link](./pages/about.md)"#, &context, @@ -500,7 +498,7 @@ fn can_make_valid_relative_link_in_header() { fn can_make_permalinks_with_colocated_assets_for_link() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content("[an image](image.jpg)", &context).unwrap(); assert_eq!( res.body, @@ -512,7 +510,7 @@ fn can_make_permalinks_with_colocated_assets_for_link() { fn can_make_permalinks_with_colocated_assets_for_image() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content("![alt text](image.jpg)", &context).unwrap(); assert_eq!( res.body, @@ -524,7 +522,7 @@ fn can_make_permalinks_with_colocated_assets_for_image() { fn markdown_doesnt_wrap_html_in_paragraph() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content(r#" Some text @@ -547,7 +545,7 @@ fn can_validate_valid_external_links() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.check_external_links = true; - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content("[a link](http://google.com)", &context).unwrap(); assert_eq!( res.body, @@ -560,7 +558,7 @@ fn can_show_error_message_for_invalid_external_links() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.check_external_links = true; - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content("[a link](http://google.comy)", &context); assert!(res.is_err()); let err = res.unwrap_err(); @@ -572,7 +570,7 @@ fn doesnt_try_to_validate_email_links_mailto() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.check_external_links = true; - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content("Email: [foo@bar.baz](mailto:foo@bar.baz)", &context).unwrap(); assert_eq!( res.body, @@ -585,7 +583,7 @@ fn doesnt_try_to_validate_email_links_angled_brackets() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.check_external_links = true; - let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); let res = render_content("Email: ", &context).unwrap(); assert_eq!( res.body, @@ -598,7 +596,7 @@ fn can_handle_summaries() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); + let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content("Hello [world]\n\n\n\nBla bla\n\n[world]: https://vincent.is/about/", &context).unwrap(); assert_eq!( res.body, diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 914ae004..32b22131 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -79,6 +79,7 @@ impl Site { pub fn new>(path: P, config_file: &str) -> Result { let path = path.as_ref(); let mut config = get_config(path, config_file); + config.load_extra_syntaxes(path)?; let tpl_glob = format!("{}/{}", path.to_string_lossy().replace("\\", "/"), "templates/**/*.*ml"); // Only parsing as we might be extending templates from themes and that would error @@ -257,7 +258,6 @@ impl Site { let permalinks = &self.permalinks; let tera = &self.tera; let config = &self.config; - let base_path = &self.base_path; // This is needed in the first place because of silly borrow checker let mut pages_insert_anchors = HashMap::new(); @@ -272,7 +272,7 @@ impl Site { .par_iter_mut() .map(|page| { let insert_anchor = pages_insert_anchors[&page.file.path]; - page.render_markdown(permalinks, tera, config, base_path, insert_anchor) + page.render_markdown(permalinks, tera, config, insert_anchor) }) .collect::>()?; @@ -281,7 +281,7 @@ impl Site { .values_mut() .collect::>() .par_iter_mut() - .map(|section| section.render_markdown(permalinks, tera, config, base_path)) + .map(|section| section.render_markdown(permalinks, tera, config)) .collect::>()?; Ok(()) @@ -319,7 +319,7 @@ impl Site { self.permalinks.insert(page.file.relative.clone(), page.permalink.clone()); if render { let insert_anchor = self.find_parent_section_insert_anchor(&page.file.parent); - page.render_markdown(&self.permalinks, &self.tera, &self.config, &self.base_path, insert_anchor)?; + page.render_markdown(&self.permalinks, &self.tera, &self.config, insert_anchor)?; } let prev = self.library.remove_page(&page.file.path); self.library.insert_page(page); @@ -334,7 +334,7 @@ impl Site { pub fn add_section(&mut self, mut section: Section, render: bool) -> Result> { self.permalinks.insert(section.file.relative.clone(), section.permalink.clone()); if render { - section.render_markdown(&self.permalinks, &self.tera, &self.config, &self.base_path)?; + section.render_markdown(&self.permalinks, &self.tera, &self.config)?; } let prev = self.library.remove_section(§ion.file.path); self.library.insert_section(section); diff --git a/sublime_syntaxes/newlines.packdump b/sublime_syntaxes/newlines.packdump index 02c5b977..a0c895ab 100644 Binary files a/sublime_syntaxes/newlines.packdump and b/sublime_syntaxes/newlines.packdump differ