mirror of
https://github.com/cobalt-org/cobalt.rs
synced 2024-11-15 00:17:29 +00:00
feat(liquid): Upgrade
Too many features, bug fixes, and performance gains to name. See https://github.com/cobalt-org/liquid-rust/blob/master/CHANGELOG.md#0180-2018-12-27 BREAKING CHANGE: Besides any caused by the liquid upgrade, we no longer support includes outside of the `_include` directory.
This commit is contained in:
parent
5c7f96f609
commit
b9981489ff
12 changed files with 249 additions and 156 deletions
174
Cargo.lock
generated
174
Cargo.lock
generated
|
@ -19,6 +19,16 @@ dependencies = [
|
|||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anymap"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.4.7"
|
||||
|
@ -109,11 +119,25 @@ name = "bitflags"
|
|||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build_const"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.2.7"
|
||||
|
@ -188,8 +212,7 @@ dependencies = [
|
|||
"itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonfeed 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"notify 4.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -316,6 +339,14 @@ name = "difference"
|
|||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.3"
|
||||
|
@ -391,6 +422,11 @@ dependencies = [
|
|||
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.3"
|
||||
|
@ -460,6 +496,14 @@ name = "futures"
|
|||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getopts"
|
||||
version = "0.2.18"
|
||||
|
@ -652,16 +696,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "liquid"
|
||||
version = "0.17.1"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-compiler 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-interpreter 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-value 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-compiler 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-interpreter 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-value 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -670,39 +714,41 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "liquid-compiler"
|
||||
version = "0.17.1"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-interpreter 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-value 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-interpreter 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-value 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "liquid-error"
|
||||
version = "0.16.1"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "liquid-interpreter"
|
||||
version = "0.17.1"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"anymap 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-value 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-value 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "liquid-value"
|
||||
version = "0.17.1"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"liquid-error 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -732,6 +778,11 @@ dependencies = [
|
|||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maplit"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
|
@ -933,6 +984,45 @@ name = "percent-encoding"
|
|||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.14"
|
||||
|
@ -1199,6 +1289,17 @@ dependencies = [
|
|||
"yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.1"
|
||||
|
@ -1378,6 +1479,16 @@ name = "typeable"
|
|||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-util"
|
||||
version = "0.1.3"
|
||||
|
@ -1551,6 +1662,8 @@ dependencies = [
|
|||
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
|
||||
"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
|
||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
"checksum anymap 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344"
|
||||
"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
|
||||
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
|
||||
"checksum assert_cmd 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ac5c260f75e4e4ba87b7342be6edcecbcb3eb6741a0507fda7ad115845cc65"
|
||||
"checksum assert_fs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "19113b89e12a291fe33e75008bee4b24334184d658278ec3e60a9871fd396473"
|
||||
|
@ -1561,7 +1674,9 @@ dependencies = [
|
|||
"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"
|
||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
||||
"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
|
||||
"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
|
||||
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
|
||||
"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
|
||||
"checksum bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0ce55bd354b095246fc34caf4e9e242f5297a7fd938b090cadfea6eee614aa62"
|
||||
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
|
||||
|
@ -1581,6 +1696,7 @@ dependencies = [
|
|||
"checksum derive_builder_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1cffc940f53a89045824e676302b840a5a60d447560704d352316e2039125a2"
|
||||
"checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690"
|
||||
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
|
||||
"checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90"
|
||||
"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd"
|
||||
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
|
||||
"checksum encoding_rs 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "5169856daf01399422d2cbaacdce579cd4f546c7a8481d3a4e926b313293ec56"
|
||||
|
@ -1590,6 +1706,7 @@ dependencies = [
|
|||
"checksum escargot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "19db1f7e74438642a5018cdf263bb1325b2e792f02dd0a3ca6d6c0f0d7b1d5a5"
|
||||
"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7"
|
||||
"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596"
|
||||
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
"checksum filetime 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b3ea0c97183a611b1673e5e28b160d7e1035106cad053c988aae3bbd996fdcce"
|
||||
"checksum flate2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3b0c7353385f92079524de3b7116cf99d73947c08a7472774e9b3b04bff3b901"
|
||||
"checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600"
|
||||
|
@ -1599,6 +1716,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 futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b"
|
||||
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
|
||||
"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
|
||||
"checksum ghp 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2381a505873cc9b3bc814214150a0da3193db84cdaf3c9eb2145c7a369d337f0"
|
||||
"checksum globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4743617a7464bbda3c8aec8558ff2f9429047e025771037df561d383337ff865"
|
||||
|
@ -1621,14 +1739,15 @@ dependencies = [
|
|||
"checksum lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddba4c30a78328befecec92fc94970e53b3ae385827d28620f0f5bb2493081e0"
|
||||
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
||||
"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e"
|
||||
"checksum liquid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "de7cbef6eb9739b9e193d68b56a017619f8e37a7f2c48d8617420f5399f384c6"
|
||||
"checksum liquid-compiler 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "270dd5631842744f3866def6a569b506db432ef5520793363b47db18f679f117"
|
||||
"checksum liquid-error 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bc16da2b35cd4538269371112f3b767206001c45955df4522a723e49cafbc964"
|
||||
"checksum liquid-interpreter 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3f74465f40bb44c9374005d5daf1aeec7b49a24d49162269af428a0c1fda09"
|
||||
"checksum liquid-value 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f19e7b1a34506fa64486f723d99213d4fecbcfbb0e3c795dc9de456e254ab02"
|
||||
"checksum liquid 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb67340d8ac41b42d168e4ac6a0ad3a5f5c73fd260c2bcf5c53b15fc569cd69"
|
||||
"checksum liquid-compiler 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "79a1111a2c02ff83cd9ca0daa128b74e658b25005709f92d9f9147b3ee9735c2"
|
||||
"checksum liquid-error 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "624cae34766c8220649cbd61e257ec80cba6412ee3a129360bbc05b803eb3721"
|
||||
"checksum liquid-interpreter 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9536173b3cc8a8b644640aa0e1d32a32d282e4443da0a8fb16f7284d9a310a89"
|
||||
"checksum liquid-value 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb18c5d6b7ded8d80b566aee6ab34bf45c1a4dd22ff59c5071726386873ae059"
|
||||
"checksum lock_api 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775751a3e69bde4df9b38dd00a1b5d6ac13791e4223d4a0506577f0dd27cfb7a"
|
||||
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
||||
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
|
||||
"checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43"
|
||||
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16"
|
||||
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
||||
|
@ -1651,6 +1770,10 @@ dependencies = [
|
|||
"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
|
||||
"checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c"
|
||||
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
||||
"checksum pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54f0c72a98d8ab3c99560bfd16df8059cc10e1f9a8e83e6e3b97718dd766e9c3"
|
||||
"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
|
||||
"checksum pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
|
||||
"checksum pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5a3492a4ed208ffc247adcdcc7ba2a95be3104f58877d0d02f0df39bf3efb5e"
|
||||
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
|
||||
"checksum plist 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c7316832d9ac5da02786bdc89a3faf0ca07070212b388766e969078fd593edc"
|
||||
"checksum predicates 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa984b7cd021a0bf5315bcce4c4ae61d2a535db2a8d288fc7578638690a7b7c3"
|
||||
|
@ -1684,6 +1807,7 @@ dependencies = [
|
|||
"checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c"
|
||||
"checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811"
|
||||
"checksum serde_yaml 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a2054770c85c7f026ad772e31ff631e65e378154ee20e85d0ada8c6ed053e63a"
|
||||
"checksum sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9d1f3b5de8a167ab06834a7c883bd197f2191e1dda1a22d9ccfeedbf9aded"
|
||||
"checksum slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9776d6b986f77b35c6cf846c11ad986ff128fe0b2b63a3628e3755e8d3102d"
|
||||
"checksum smallvec 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "622df2d454c29a4d89b30dc3b27b42d7d90d6b9e587dbf8f67652eb7514da484"
|
||||
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
||||
|
@ -1704,6 +1828,8 @@ dependencies = [
|
|||
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
|
||||
"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
||||
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
|
||||
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
|
||||
"checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77"
|
||||
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
|
||||
"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
|
||||
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
||||
|
|
|
@ -22,8 +22,7 @@ doc = false
|
|||
|
||||
[dependencies]
|
||||
clap = "2.32"
|
||||
liquid = "0.17.0"
|
||||
liquid-error = "0.16.0"
|
||||
liquid = "0.18.0"
|
||||
deunicode = "0.4.1"
|
||||
walkdir = "2.2"
|
||||
chrono = "0.4"
|
||||
|
|
|
@ -82,8 +82,8 @@ impl CollectionBuilder {
|
|||
.map_or(Ok(None), |r| r.map(Some))?;
|
||||
|
||||
let mut attributes: liquid::value::Object = vec![
|
||||
("title".into(), liquid::value::Value::scalar(&title)),
|
||||
("slug".into(), liquid::value::Value::scalar(&slug)),
|
||||
("title".into(), liquid::value::Value::scalar(title.clone())),
|
||||
("slug".into(), liquid::value::Value::scalar(slug.clone())),
|
||||
(
|
||||
"description".into(),
|
||||
liquid::value::Value::scalar(description.clone().unwrap_or_else(|| "".to_owned())),
|
||||
|
@ -92,10 +92,10 @@ impl CollectionBuilder {
|
|||
.into_iter()
|
||||
.collect();
|
||||
if let Some(ref rss) = rss {
|
||||
attributes.insert("rss".into(), liquid::value::Value::scalar(rss));
|
||||
attributes.insert("rss".into(), liquid::value::Value::scalar(rss.to_owned()));
|
||||
}
|
||||
if let Some(ref jsonfeed) = jsonfeed {
|
||||
attributes.insert("jsonfeed".into(), liquid::value::Value::scalar(jsonfeed));
|
||||
attributes.insert("jsonfeed".into(), liquid::value::Value::scalar(jsonfeed.to_owned()));
|
||||
}
|
||||
|
||||
let default = default.set_collection(slug.clone());
|
||||
|
|
|
@ -388,7 +388,6 @@ impl ConfigBuilder {
|
|||
|
||||
let liquid = template::LiquidBuilder {
|
||||
includes_dir: includes_dir.clone(),
|
||||
legacy_path: source.clone(),
|
||||
theme: syntax_highlight.theme.clone(),
|
||||
};
|
||||
let markdown = mark::MarkdownBuilder {
|
||||
|
|
|
@ -80,8 +80,9 @@ fn deep_insert(
|
|||
)
|
||||
})?;
|
||||
let cur_map = map;
|
||||
let key: ::std::borrow::Cow<'static, str> = key.to_owned().into();
|
||||
map = cur_map
|
||||
.entry(String::from(key).into())
|
||||
.entry(key)
|
||||
.or_insert_with(|| liquid::value::Value::Object(liquid::value::Object::new()))
|
||||
.as_object_mut()
|
||||
.ok_or_else(|| {
|
||||
|
|
|
@ -1,93 +1,47 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::path;
|
||||
use std::result;
|
||||
|
||||
use super::files;
|
||||
use error::*;
|
||||
use liquid;
|
||||
use syntax_highlight;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct InMemoryInclude {
|
||||
templates: HashMap<String, String>,
|
||||
legacy: Option<liquid::compiler::FilesystemInclude>,
|
||||
}
|
||||
fn load_partials_from_path(root: path::PathBuf) -> Result<liquid::Partials> {
|
||||
let mut source = liquid::Partials::empty();
|
||||
|
||||
impl InMemoryInclude {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
pub fn load_from_path<R: Into<path::PathBuf>>(self, root: R) -> Result<Self> {
|
||||
self.load_from_pathbuf(root.into())
|
||||
}
|
||||
|
||||
/// Overwrites previous, conflicting snippets
|
||||
fn load_from_pathbuf(mut self, root: path::PathBuf) -> Result<Self> {
|
||||
debug!("Loading snippets from {:?}", root);
|
||||
let template_files = files::FilesBuilder::new(root)?
|
||||
.ignore_hidden(false)?
|
||||
.build()?;
|
||||
for file_path in template_files.files() {
|
||||
let rel_path = file_path
|
||||
.strip_prefix(template_files.root())
|
||||
.expect("file was found under the root")
|
||||
.to_str()
|
||||
.expect("only UTF-8 characters supported in paths")
|
||||
.to_owned();
|
||||
trace!("Loading snippet {:?}", rel_path);
|
||||
let content = files::read_file(file_path)?;
|
||||
self.templates.insert(rel_path, content);
|
||||
}
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn set_legacy_path(mut self, legacy_path: Option<path::PathBuf>) -> Self {
|
||||
self.legacy = legacy_path.map(liquid::compiler::FilesystemInclude::new);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl liquid::compiler::Include for InMemoryInclude {
|
||||
fn include(&self, path: &str) -> result::Result<String, liquid::Error> {
|
||||
self.templates
|
||||
.get(path)
|
||||
.map(|s| Ok(s.to_owned()))
|
||||
.unwrap_or_else(|| {
|
||||
let content = self
|
||||
.legacy
|
||||
.as_ref()
|
||||
.ok_or_else(|| liquid::Error::with_msg("No legacy path specified"))?
|
||||
.include(path)?;
|
||||
warn!(
|
||||
"Loading `include`s relative to `source` is deprecated, see {}.",
|
||||
path
|
||||
);
|
||||
Ok(content)
|
||||
})
|
||||
debug!("Loading snippets from {:?}", root);
|
||||
let template_files = files::FilesBuilder::new(root)?
|
||||
.ignore_hidden(false)?
|
||||
.build()?;
|
||||
for file_path in template_files.files() {
|
||||
let rel_path = file_path
|
||||
.strip_prefix(template_files.root())
|
||||
.expect("file was found under the root")
|
||||
.to_str()
|
||||
.expect("only UTF-8 characters supported in paths")
|
||||
.to_owned();
|
||||
trace!("Loading snippet {:?}", rel_path);
|
||||
let content = files::read_file(file_path)?;
|
||||
source.add(rel_path, content);
|
||||
}
|
||||
Ok(source)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct LiquidBuilder {
|
||||
pub includes_dir: path::PathBuf,
|
||||
pub legacy_path: path::PathBuf,
|
||||
pub theme: String,
|
||||
}
|
||||
|
||||
impl LiquidBuilder {
|
||||
pub fn build(self) -> Result<Liquid> {
|
||||
let repo = InMemoryInclude::new()
|
||||
.load_from_path(self.includes_dir)?
|
||||
.set_legacy_path(Some(self.legacy_path));
|
||||
let highlight = Self::highlight(self.theme)?;
|
||||
let parser = liquid::ParserBuilder::with_liquid()
|
||||
.extra_filters()
|
||||
.include_source(Box::new(repo))
|
||||
.partials(load_partials_from_path(self.includes_dir)?)
|
||||
.block("highlight", highlight)
|
||||
.build();
|
||||
.build()?;
|
||||
Ok(Liquid { parser })
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ pub fn permalink_attributes(front: &cobalt_model::Frontmatter, dest_file: &Path)
|
|||
// TODO(epage): Add `collection` (the collection's slug), see #257
|
||||
// or `parent.slug`, see #323
|
||||
|
||||
attributes.insert("slug".into(), Value::scalar(&front.slug));
|
||||
attributes.insert("slug".into(), Value::scalar(front.slug.clone()));
|
||||
|
||||
attributes.insert(
|
||||
"categories".into(),
|
||||
|
@ -96,7 +96,7 @@ fn document_attributes(
|
|||
source_file: &Path,
|
||||
url_path: &str,
|
||||
) -> Object {
|
||||
let categories = Value::Array(front.categories.iter().map(Value::scalar).collect());
|
||||
let categories = Value::Array(front.categories.iter().cloned().map(Value::scalar).collect());
|
||||
// Reason for `file`:
|
||||
// - Allow access to assets in the original location
|
||||
// - Ease linking back to page's source
|
||||
|
@ -120,8 +120,8 @@ fn document_attributes(
|
|||
.collect();
|
||||
let attributes = vec![
|
||||
("permalink".into(), Value::scalar(url_path.to_owned())),
|
||||
("title".into(), Value::scalar(&front.title)),
|
||||
("slug".into(), Value::scalar(&front.slug)),
|
||||
("title".into(), Value::scalar(front.title.clone())),
|
||||
("slug".into(), Value::scalar(front.slug.clone())),
|
||||
(
|
||||
"description".into(),
|
||||
Value::scalar(
|
||||
|
@ -136,13 +136,13 @@ fn document_attributes(
|
|||
("categories".into(), categories),
|
||||
("is_draft".into(), Value::scalar(front.is_draft)),
|
||||
("file".into(), Value::Object(file)),
|
||||
("collection".into(), Value::scalar(&front.collection)),
|
||||
("collection".into(), Value::scalar(front.collection.clone())),
|
||||
("data".into(), Value::Object(front.data.clone())),
|
||||
];
|
||||
let mut attributes: Object = attributes.into_iter().collect();
|
||||
|
||||
if let Some(ref tags) = front.tags {
|
||||
let tags = Value::Array(tags.iter().map(Value::scalar).collect());
|
||||
let tags = Value::Array(tags.iter().cloned().map(Value::scalar).collect());
|
||||
attributes.insert("tags".into(), tags);
|
||||
}
|
||||
|
||||
|
@ -255,8 +255,8 @@ impl Document {
|
|||
self.front
|
||||
.description
|
||||
.clone()
|
||||
.or_else(|| self.attributes.get("excerpt").map(|s| s.to_string()))
|
||||
.or_else(|| self.attributes.get("content").map(|s| s.to_string()))
|
||||
.or_else(|| self.attributes.get("excerpt").map(|s| s.render().to_string()))
|
||||
.or_else(|| self.attributes.get("content").map(|s| s.render().to_string()))
|
||||
}
|
||||
|
||||
/// Renders liquid templates into HTML in the context of current document.
|
||||
|
@ -354,6 +354,7 @@ impl Document {
|
|||
.ok_or("Internal error: page isn't in globals")?
|
||||
.get(&liquid::value::Scalar::new("content"))
|
||||
.ok_or("Internal error: page.content isn't in globals")?
|
||||
.render()
|
||||
.to_string();
|
||||
|
||||
Ok(content_html)
|
||||
|
|
|
@ -6,7 +6,6 @@ extern crate ignore;
|
|||
extern crate itertools;
|
||||
extern crate jsonfeed;
|
||||
extern crate liquid;
|
||||
extern crate liquid_error;
|
||||
extern crate normalize_line_endings;
|
||||
extern crate pulldown_cmark;
|
||||
extern crate regex;
|
||||
|
|
|
@ -101,7 +101,7 @@ impl Into<liquid::value::Object> for Paginator {
|
|||
object.insert(
|
||||
"indexes".into(),
|
||||
liquid::value::Value::Array(
|
||||
indexes.iter().map(liquid::value::Value::scalar).collect(),
|
||||
indexes.iter().cloned().map(liquid::value::Value::scalar).collect(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -183,10 +183,10 @@ fn extract_value<'a>(a: &'a liquid::value::Value, key: &str) -> Option<&'a liqui
|
|||
fn sort_posts(posts: &mut Vec<&liquid::value::Value>, config: &PaginationConfig) {
|
||||
let order: fn(&liquid::value::Scalar, &liquid::value::Scalar) -> Ordering = match config.order {
|
||||
SortOrder::Desc => {
|
||||
|a, b: &liquid::value::Scalar| b.partial_cmp(&a).unwrap_or(Ordering::Equal)
|
||||
|a, b: &liquid::value::Scalar| b.partial_cmp(a).unwrap_or(Ordering::Equal)
|
||||
}
|
||||
SortOrder::Asc => {
|
||||
|a: &liquid::value::Scalar, b| a.partial_cmp(&b).unwrap_or(Ordering::Equal)
|
||||
|a: &liquid::value::Scalar, b| a.partial_cmp(b).unwrap_or(Ordering::Equal)
|
||||
}
|
||||
SortOrder::None => {
|
||||
// when built, order is set like this:
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use std::io::Write;
|
||||
|
||||
use liquid;
|
||||
use liquid::compiler::Element::{self, Expression, Raw, Tag};
|
||||
use liquid::compiler::LiquidOptions;
|
||||
use liquid::compiler::Token::{self, Identifier};
|
||||
use liquid::compiler::Language;
|
||||
use liquid::compiler::TagBlock;
|
||||
use liquid::compiler::TagTokenIter;
|
||||
use liquid::compiler::TryMatchToken;
|
||||
use liquid::error::ResultLiquidReplaceExt;
|
||||
use liquid::interpreter::{Context, Renderable};
|
||||
use liquid_error::ResultLiquidChainExt;
|
||||
use pulldown_cmark as cmark;
|
||||
|
||||
use error;
|
||||
|
@ -72,9 +73,9 @@ impl Renderable for CodeBlock {
|
|||
"<pre><code class=\"language-{}\">{}</code></pre>",
|
||||
lang, self.code
|
||||
)
|
||||
.chain("Failed to render")?;
|
||||
.replace("Failed to render")?;
|
||||
} else {
|
||||
write!(writer, "<pre><code>{}</code></pre>", self.code).chain("Failed to render")?;
|
||||
write!(writer, "<pre><code>{}</code></pre>", self.code).replace("Failed to render")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -93,24 +94,31 @@ impl liquid::compiler::ParseBlock for CodeBlockParser {
|
|||
fn parse(
|
||||
&self,
|
||||
_tag_name: &str,
|
||||
arguments: &[Token],
|
||||
tokens: &[Element],
|
||||
_options: &LiquidOptions,
|
||||
mut arguments: TagTokenIter,
|
||||
mut tokens: TagBlock,
|
||||
_options: &Language,
|
||||
) -> Result<Box<Renderable>, liquid::Error> {
|
||||
let content = tokens.iter().fold("".to_owned(), |a, b| {
|
||||
match *b {
|
||||
Expression(_, ref text) | Tag(_, ref text) | Raw(ref text) => text,
|
||||
}
|
||||
.to_owned()
|
||||
+ &a
|
||||
});
|
||||
|
||||
let lang = match arguments.iter().next() {
|
||||
Some(&Identifier(ref x)) => Some(x.clone()),
|
||||
_ => None,
|
||||
};
|
||||
let lang = arguments
|
||||
.expect_next("Identifier or literal expected.")
|
||||
.ok()
|
||||
.map(|lang| {
|
||||
// This may accept strange inputs such as `{% include 0 %}` or `{% include filterchain | filter:0 %}`.
|
||||
// Those inputs would fail anyway by there being not a path with those langs so they are not a big concern.
|
||||
match lang.expect_literal() {
|
||||
// Using `to_str()` on literals ensures `Strings` will have their quotes trimmed.
|
||||
TryMatchToken::Matches(lang) => lang.to_str().to_string(),
|
||||
TryMatchToken::Fails(lang) => lang.as_str().to_string(),
|
||||
}
|
||||
});
|
||||
// no more arguments should be supplied, trying to supply them is an error
|
||||
arguments.expect_nothing()?;
|
||||
|
||||
let mut content = String::new();
|
||||
while let Some(element) = tokens.next()? {
|
||||
content.push_str(element.as_str());
|
||||
}
|
||||
let content = html_escape(&content);
|
||||
tokens.assert_empty();
|
||||
|
||||
Ok(Box::new(CodeBlock {
|
||||
lang: lang,
|
||||
|
@ -150,7 +158,8 @@ mod test {
|
|||
Box::new(CodeBlockParser::new("base16-ocean.dark".to_owned()));
|
||||
let parser = liquid::ParserBuilder::new()
|
||||
.block("highlight", highlight)
|
||||
.build();
|
||||
.build()
|
||||
.unwrap();
|
||||
let template = parser
|
||||
.parse(&format!(
|
||||
"{{% highlight rust %}}{}{{% endhighlight %}}",
|
||||
|
|
|
@ -3,11 +3,12 @@ use std::io::Write;
|
|||
|
||||
use itertools::Itertools;
|
||||
use liquid;
|
||||
use liquid::compiler::Element::{self, Expression, Raw, Tag};
|
||||
use liquid::compiler::LiquidOptions;
|
||||
use liquid::compiler::Token::{self, Identifier};
|
||||
use liquid::compiler::TagBlock;
|
||||
use liquid::compiler::TagTokenIter;
|
||||
use liquid::compiler::TryMatchToken;
|
||||
use liquid::compiler::Language;
|
||||
use liquid::interpreter::{Context, Renderable};
|
||||
use liquid_error::ResultLiquidChainExt;
|
||||
use liquid::error::ResultLiquidReplaceExt;
|
||||
use pulldown_cmark as cmark;
|
||||
use pulldown_cmark::Event::{self, End, Html, Start, Text};
|
||||
use syntect::easy::HighlightLines;
|
||||
|
@ -81,8 +82,7 @@ impl Renderable for CodeBlock {
|
|||
writer,
|
||||
"{}",
|
||||
highlighted_html_for_string(&self.code, &SETUP.syntax_set, syntax, &self.theme,)
|
||||
)
|
||||
.chain("Failed to render")?;
|
||||
).replace("Failed to render")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -103,22 +103,30 @@ impl liquid::compiler::ParseBlock for CodeBlockParser {
|
|||
fn parse(
|
||||
&self,
|
||||
_tag_name: &str,
|
||||
arguments: &[Token],
|
||||
tokens: &[Element],
|
||||
_options: &LiquidOptions,
|
||||
mut arguments: TagTokenIter,
|
||||
mut tokens: TagBlock,
|
||||
_options: &Language,
|
||||
) -> Result<Box<Renderable>, liquid::Error> {
|
||||
let content = tokens.iter().fold("".to_owned(), |a, b| {
|
||||
match *b {
|
||||
Expression(_, ref text) | Tag(_, ref text) | Raw(ref text) => text,
|
||||
}
|
||||
.to_owned()
|
||||
+ &a
|
||||
});
|
||||
let lang = arguments
|
||||
.expect_next("Identifier or literal expected.")
|
||||
.ok()
|
||||
.map(|lang| {
|
||||
// This may accept strange inputs such as `{% include 0 %}` or `{% include filterchain | filter:0 %}`.
|
||||
// Those inputs would fail anyway by there being not a path with those langs so they are not a big concern.
|
||||
match lang.expect_literal() {
|
||||
// Using `to_str()` on literals ensures `Strings` will have their quotes trimmed.
|
||||
TryMatchToken::Matches(lang) => lang.to_str().to_string(),
|
||||
TryMatchToken::Fails(lang) => lang.as_str().to_string(),
|
||||
}
|
||||
});
|
||||
// no more arguments should be supplied, trying to supply them is an error
|
||||
arguments.expect_nothing()?;
|
||||
|
||||
let lang = match arguments.iter().next() {
|
||||
Some(&Identifier(ref x)) => Some(x.clone()),
|
||||
_ => None,
|
||||
};
|
||||
let mut content = String::new();
|
||||
while let Some(element) = tokens.next()? {
|
||||
content.push_str(element.as_str());
|
||||
}
|
||||
tokens.assert_empty();
|
||||
|
||||
Ok(Box::new(CodeBlock {
|
||||
code: content,
|
||||
|
@ -224,7 +232,8 @@ mod test {
|
|||
Box::new(CodeBlockParser::new("base16-ocean.dark".to_owned()));
|
||||
let parser = liquid::ParserBuilder::new()
|
||||
.block("highlight", highlight)
|
||||
.build();
|
||||
.build()
|
||||
.unwrap();
|
||||
let template = parser
|
||||
.parse(&format!(
|
||||
"{{% highlight rust %}}{}{{% endhighlight %}}",
|
||||
|
|
|
@ -168,10 +168,6 @@ pub fn incomplete_rss() {
|
|||
pub fn liquid_error() {
|
||||
let err = run_test("liquid_error");
|
||||
assert!(err.is_err());
|
||||
assert_contains!(
|
||||
format!("{}", err.unwrap_err().display_chain()),
|
||||
"Invalid identifier"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue