diff --git a/.gitmodules b/.gitmodules index ffd0dd08..5b033dde 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,68 +2,71 @@ path = sublime/syntaxes/Packages url = https://github.com/sublimehq/Packages.git [submodule "sublime/syntaxes/awk-sublime"] - path = sublime/syntaxes/awk-sublime + path = sublime/syntaxes/extra/awk-sublime url = https://github.com/JohnNilsson/awk-sublime.git [submodule "sublime/syntaxes/AsciiDoc"] path = sublime/syntaxes/AsciiDoc url = https://github.com/SublimeText/AsciiDoc.git [submodule "sublime/syntaxes/Sublime-CMakeLists"] - path = sublime/syntaxes/Sublime-CMakeLists + path = sublime/syntaxes/extra/Sublime-CMakeLists url = https://github.com/zyxar/Sublime-CMakeLists.git [submodule "sublime/syntaxes/SublimeTextLinkerSyntax"] - path = sublime/syntaxes/SublimeTextLinkerSyntax + path = sublime/syntaxes/extra/SublimeTextLinkerSyntax url = https://github.com/jbw3/SublimeTextLinkerSyntax [submodule "sublime/syntaxes/Docker.tmbundle"] - path = sublime/syntaxes/Docker.tmbundle + path = sublime/syntaxes/extra/Docker.tmbundle url = https://github.com/asbjornenge/Docker.tmbundle.git [submodule "sublime/syntaxes/Sublime-VimL"] path = sublime/syntaxes/Sublime-VimL url = https://github.com/SalGnt/Sublime-VimL.git [submodule "sublime/syntaxes/elixir-sublime-syntax"] - path = sublime/syntaxes/elixir-sublime-syntax + path = sublime/syntaxes/extra/elixir-sublime-syntax url = https://github.com/princemaple/elixir-sublime-syntax.git [submodule "sublime/syntaxes/SublimeElmLanguageSupport"] - path = sublime/syntaxes/SublimeElmLanguageSupport + path = sublime/syntaxes/extra/SublimeElmLanguageSupport url = https://github.com/elm-community/SublimeElmLanguageSupport.git [submodule "sublime/syntaxes/sublimetext-fsharp"] - path = sublime/syntaxes/sublimetext-fsharp + path = sublime/syntaxes/extra/sublimetext-fsharp url = https://github.com/hoest/sublimetext-fsharp.git [submodule "sublime/syntaxes/sublime-fish"] - path = sublime/syntaxes/sublime-fish + path = sublime/syntaxes/extra/sublime-fish url = https://github.com/Phidica/sublime-fish.git [submodule "sublime/syntaxes/SublimeFortran"] - path = sublime/syntaxes/SublimeFortran + path = sublime/syntaxes/extra/SublimeFortran url = https://github.com/315234/SublimeFortran.git [submodule "sublime/syntaxes/GraphQL-SublimeText3"] - path = sublime/syntaxes/GraphQL-SublimeText3 + path = sublime/syntaxes/extra/GraphQL-SublimeText3 url = https://github.com/dncrews/GraphQL-SublimeText3.git [submodule "sublime/syntaxes/Sublime-GenericConfig"] - path = sublime/syntaxes/Sublime-GenericConfig + path = sublime/syntaxes/extra/Sublime-GenericConfig url = https://github.com/skozlovf/Sublime-GenericConfig.git [submodule "sublime/syntaxes/sublime-jinja2"] - path = sublime/syntaxes/sublime-jinja2 + path = sublime/syntaxes/extra/sublime-jinja2 url = https://github.com/Martin819/sublime-jinja2.git [submodule "sublime/syntaxes/Julia-sublime"] - path = sublime/syntaxes/Julia-sublime + path = sublime/syntaxes/extra/Julia-sublime url = https://github.com/JuliaEditorSupport/Julia-sublime.git [submodule "sublime/syntaxes/LESS-sublime"] - path = sublime/syntaxes/LESS-sublime + path = sublime/syntaxes/extra/LESS-sublime url = https://github.com/danro/LESS-sublime.git [submodule "sublime/syntaxes/sublime-purescript-syntax"] - path = sublime/syntaxes/sublime-purescript-syntax + path = sublime/syntaxes/extra/sublime-purescript-syntax url = https://github.com/tellnobody1/sublime-purescript-syntax.git [submodule "sublime/syntaxes/SublimeSass"] - path = sublime/syntaxes/SublimeSass + path = sublime/syntaxes/extra/SublimeSass url = https://github.com/braver/SublimeSass.git [submodule "sublime/syntaxes/sublime_toml_highlighting"] - path = sublime/syntaxes/sublime_toml_highlighting + path = sublime/syntaxes/extra/sublime_toml_highlighting url = https://github.com/jasonwilliams/sublime_toml_highlighting.git [submodule "sublime/syntaxes/vue-syntax-highlight"] - path = sublime/syntaxes/vue-syntax-highlight + path = sublime/syntaxes/extra/vue-syntax-highlight url = https://github.com/vuejs/vue-syntax-highlight.git [submodule "sublime/syntaxes/sublime-glsl"] - path = sublime/syntaxes/sublime-glsl + path = sublime/syntaxes/extra/sublime-glsl url = https://github.com/euler0/sublime-glsl.git [submodule "sublime/syntaxes/GDScript-sublime"] - path = sublime/syntaxes/GDScript-sublime + path = sublime/syntaxes/extra/GDScript-sublime url = https://github.com/beefsack/GDScript-sublime.git +[submodule "sublime/syntaxes/extra/sublime-clojure"] + path = sublime/syntaxes/extra/sublime-clojure + url = https://github.com/tonsky/sublime-clojure.git diff --git a/CHANGELOG.md b/CHANGELOG.md index e6fc5fa2..876bcc3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## 0.13.0 (2021-01-09) + +- Enable HTML minification +- Support `output_dir` in `config.toml` +- Allow sections to be drafted +- Allow specifying default language in filenames +- Render emoji in Markdown content if the `render_emoji` option is enabled +- Enable YouTube privacy mode for the YouTube shortcode +- Add language as class to the `` block and as `data-lang` +- Add bibtex to `load_data` +- Add a `[markdown]` section to `config.toml` to configure rendering +- Add `highlight_code` and `highlight_theme` to a `[markdown]` section in `config.toml` +- Add `external_links_target_blank`, `external_links_no_follow` and `external_links_no_referrer` +- Add a `smart_punctuation` option in the `[markdown]` section in `config.toml` to turn elements like dots and dashes +into their typographic forms +- Add iteration count variable `nth` for shortcodes to know how many times a shortcode has been invoked in a given +content +- Update some highlighting syntaxes and the TS syntax will now be used instead of JS due to issues with it +- Remove `zola serve --watch-only`: since we build the HTML in memory and not on disk, it doesn't make sense anymore +- Update clojure syntax +- Prefer extra syntaxes to the default ones if we have a match for language +- Fix `zola serve` having issues with non-ascii paths +- 404 page now gets the site default language as `lang` + ## 0.12.2 (2020-09-28) - Fix `zola serve` being broken on reload diff --git a/Cargo.lock b/Cargo.lock index 79976fb5..5225d59f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" [[package]] name = "aho-corasick" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -51,6 +51,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "assert-json-diff" version = "1.1.0" @@ -81,9 +87,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "base64" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bincode" @@ -133,9 +139,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" +checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" dependencies = [ "lazy_static", "memchr", @@ -155,6 +161,18 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +[[package]] +name = "bytecount" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f861d9ce359f56dbcb6e0c2a1cb84e52ad732cadb57b806adeb3c7668caccbd8" + +[[package]] +name = "bytecount" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" + [[package]] name = "bytemuck" version = "1.4.1" @@ -163,9 +181,9 @@ checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -179,15 +197,15 @@ dependencies = [ [[package]] name = "bytes" -version = "0.5.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +checksum = "ad1f8e949d755f9d79112b5bb46938e0ef9d3804a0b16dfab13aafcaa5f0fa72" [[package]] name = "cc" -version = "1.0.60" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" [[package]] name = "cedarwood" @@ -205,10 +223,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] -name = "chrono" -version = "0.4.18" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d021fddb7bd3e734370acfa4a83f34095571d8570c039f1420d77540f68d5772" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ "libc", "num-integer", @@ -245,9 +269,9 @@ dependencies = [ [[package]] name = "color_quant" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colored" @@ -275,6 +299,12 @@ dependencies = [ "utils", ] +[[package]] +name = "const_fn" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" + [[package]] name = "cpuid-bool" version = "0.1.2" @@ -283,65 +313,64 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "crc32fast" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] name = "crossbeam-channel" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ + "cfg-if 1.0.0", "crossbeam-utils", - "maybe-uninit", ] [[package]] name = "crossbeam-deque" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", - "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ - "autocfg", - "cfg-if", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", "lazy_static", - "maybe-uninit", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ "autocfg", - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] [[package]] name = "csv" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" +checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" dependencies = [ "bstr", "csv-core", @@ -361,9 +390,9 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.1.6" +version = "3.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b676fa23f995faf587496dcd1c80fead847ed58d2da52ac1caca9a72790dd2" +checksum = "b57a92e9749e10f25a171adcebfafe72991d45e7ec2dcb853e8f83d9dafaeb08" dependencies = [ "nix", "winapi 0.3.9", @@ -417,9 +446,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dtoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" [[package]] name = "either" @@ -511,11 +540,11 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" [[package]] name = "encoding_rs" -version = "0.8.24" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" +checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -548,11 +577,11 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "filetime" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" +checksum = "0c122a393ea57648015bf06fbd3d372378992e86b9ff5a7a497b076a28c79efe" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "winapi 0.3.9", @@ -560,14 +589,14 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.17" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" +checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crc32fast", "libc", - "miniz_oxide 0.4.2", + "miniz_oxide 0.4.3", ] [[package]] @@ -576,6 +605,16 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" +dependencies = [ + "matches", + "percent-encoding", +] + [[package]] name = "front_matter" version = "0.1.0" @@ -586,7 +625,9 @@ dependencies = [ "regex", "serde", "serde_derive", + "serde_yaml", "tera", + "test-case", "toml", "utils", ] @@ -638,30 +679,30 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "f01c61843314e95f96cc9245702248733a3a3d744e43e2e755e3c7af8348a0a9" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "db8d3b0917ff63a2a96173133c02818fac4a746b0a57569d3baca9ec0e945e08" [[package]] name = "futures-io" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +checksum = "e37c1a51b037b80922864b8eed90692c5cd8abd4c71ce49b77146caa47f3253b" [[package]] name = "futures-macro" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +checksum = "0f8719ca0e1f3c5e34f3efe4570ef2c0610ca6da85ae7990d472e9cbfba13664" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -671,31 +712,31 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +checksum = "f6adabac1290109cfa089f79192fb6244ad2c3f1cc2281f3e1dd987592b71feb" [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +checksum = "a92a0843a2ff66823a8f7c77bffe9a09be2b64e533562c412d63075643ec0038" dependencies = [ "once_cell", ] [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "036a2107cdeb57f6d7322f1b6c363dad67cd63ca3b7d1b925bdf75bd5d96cda9" dependencies = [ "futures-core", "futures-io", "futures-macro", "futures-task", "memchr", - "pin-project", + "pin-project-lite", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -723,15 +764,36 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.1+wasi-snapshot-preview1", +] + +[[package]] +name = "gh-emoji" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17a050b7eb420553344e1cf1db648e8b584c79e98b74e6e6d119eeedd9ddcbc" +dependencies = [ + "phf", + "regex", +] + [[package]] name = "gif" version = "0.11.1" @@ -750,9 +812,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" dependencies = [ "aho-corasick", "bstr", @@ -763,9 +825,9 @@ dependencies = [ [[package]] name = "globwalk" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "178270263374052c40502e9f607134947de75302c1348d1a0e31db67c1691446" +checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" dependencies = [ "bitflags", "ignore", @@ -774,11 +836,11 @@ dependencies = [ [[package]] name = "h2" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" dependencies = [ - "bytes 0.5.6", + "bytes 1.0.0", "fnv", "futures-core", "futures-sink", @@ -789,6 +851,7 @@ dependencies = [ "tokio", "tokio-util", "tracing", + "tracing-futures", ] [[package]] @@ -801,26 +864,20 @@ dependencies = [ "autocfg", ] -[[package]] -name = "hashbrown" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" - [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" dependencies = [ "libc", ] @@ -841,22 +898,22 @@ dependencies = [ [[package]] name = "http" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 0.5.6", + "bytes 1.0.0", "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ - "bytes 0.5.6", + "bytes 1.0.0", "http", ] @@ -880,11 +937,11 @@ checksum = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" [[package]] name = "hyper" -version = "0.13.8" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" +checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" dependencies = [ - "bytes 0.5.6", + "bytes 1.0.0", "futures-channel", "futures-core", "futures-util", @@ -894,7 +951,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project", + "pin-project 1.0.3", "socket2", "tokio", "tower-service", @@ -904,11 +961,10 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.21.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6" +checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" dependencies = [ - "bytes 0.5.6", "futures-util", "hyper", "log", @@ -918,23 +974,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "hyper-staticfile" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f059991575d4be26e3946276a4f3ee24bcf17a232449407354045eaf064d3475" -dependencies = [ - "chrono", - "futures-util", - "http", - "hyper", - "mime_guess", - "percent-encoding", - "tokio", - "url", - "winapi 0.3.9", -] - [[package]] name = "idna" version = "0.2.0" @@ -948,9 +987,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22dcbf2a4a289528dbef21686354904e1c694ac642610a9bff9e7df730d9ec72" +checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" dependencies = [ "crossbeam-utils", "globset", @@ -966,12 +1005,13 @@ dependencies = [ [[package]] name = "image" -version = "0.23.10" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "985fc06b1304d19c28d5c562ed78ef5316183f2b0053b46763a0b94862373c34" +checksum = "7ce04077ead78e39ae8610ad26216aed811996b043d47beed5090db674f9e9b5" dependencies = [ "bytemuck", "byteorder", + "color_quant", "gif", "jpeg-decoder", "num-iter", @@ -997,12 +1037,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4e47a3566dd4fd4eec714ae6ceabdee0caec795be835c223d92c2d40f1e8cf1c" dependencies = [ "autocfg", - "hashbrown 0.9.0", + "hashbrown", ] [[package]] @@ -1018,9 +1058,9 @@ dependencies = [ [[package]] name = "inotify-sys" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" +checksum = "c4563555856585ab3180a5bf0b2f9f8d301a728462afffc8195b3f5394229c55" dependencies = [ "libc", ] @@ -1042,9 +1082,9 @@ checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jieba-rs" @@ -1053,7 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ca2de723e93727460917d9542f7ae35a74d03d93923f03380a0238d860d137c" dependencies = [ "cedarwood", - "hashbrown 0.8.2", + "hashbrown", "lazy_static", "phf", "phf_codegen", @@ -1072,9 +1112,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" +checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" dependencies = [ "wasm-bindgen", ] @@ -1108,10 +1148,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73a004f877f468548d8d0ac4977456a249d8fabbdb8416c36db163dfc8f2e8ca" [[package]] -name = "libc" -version = "0.2.77" +name = "lexical-core" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" +checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616" +dependencies = [ + "arrayvec", + "bitflags", + "cfg-if 0.1.10", + "ryu", + "static_assertions", +] + +[[package]] +name = "libc" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" [[package]] name = "library" @@ -1221,9 +1274,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "log" @@ -1231,15 +1284,9 @@ version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] -[[package]] -name = "lzw" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" - [[package]] name = "mac" version = "0.1.1" @@ -1287,23 +1334,17 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] @@ -1314,21 +1355,11 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "mime_guess" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "minify-html" -version = "0.3.8" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30f114c59124a0424fff930aecd3c3b991fc9a775bf656ecd9b659975d1b9658" +checksum = "345dcbf4663db7d3a78a6e6b6c279c8bb6c32d6365cd98da977d7f7543b6c167" dependencies = [ "aho-corasick", "lazy_static", @@ -1346,9 +1377,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", "autocfg", @@ -1356,23 +1387,36 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "fuchsia-zircon", "fuchsia-zircon-sys", "iovec", "kernel32-sys", "libc", "log", - "miow", + "miow 0.2.2", "net2", "slab", "winapi 0.2.8", ] +[[package]] +name = "mio" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7" +dependencies = [ + "libc", + "log", + "miow 0.3.6", + "ntapi", + "winapi 0.3.9", +] + [[package]] name = "mio-extras" version = "2.0.6" @@ -1381,15 +1425,15 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log", - "mio", + "mio 0.6.23", "slab", ] [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -1398,10 +1442,20 @@ dependencies = [ ] [[package]] -name = "mockito" -version = "0.27.0" +name = "miow" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a634720d366bcbce30fb05871a35da229cef101ad0b2ea4e46cf5abf031a273" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" +dependencies = [ + "socket2", + "winapi 0.3.9", +] + +[[package]] +name = "mockito" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36a0eb7e686b49b02c1cb87c14b8e2a05de0d36c6eee0293653d0a875906d499" dependencies = [ "assert-json-diff", "colored", @@ -1409,19 +1463,19 @@ dependencies = [ "httparse", "lazy_static", "log", - "rand", + "rand 0.7.3", "regex", "serde_json", - "serde_urlencoded", + "serde_urlencoded 0.6.1", ] [[package]] name = "net2" -version = "0.2.35" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "winapi 0.3.9", ] @@ -1434,15 +1488,81 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "nix" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" +checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" dependencies = [ "bitflags", "cc", - "cfg-if", + "cfg-if 0.1.10", "libc", - "void", +] + +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "lexical-core", + "memchr", + "version_check", +] + +[[package]] +name = "nom-bibtex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9db257f6c7b9c8b3ab67ee6a4b23a290c157d183fef2ac065bf9fce5f1c1299" +dependencies = [ + "nom", + "nom-tracable", + "nom_locate 2.1.0", + "quick-error", +] + +[[package]] +name = "nom-tracable" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e012c742e1269f801f6bfe0d1ebf99d7a3f7bc1d65c970bab0e7bee439e31610" +dependencies = [ + "nom", + "nom-tracable-macros", + "nom_locate 1.0.0", + "nom_locate 2.1.0", +] + +[[package]] +name = "nom-tracable-macros" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65ad630ff46d4c61da89042f327e6fdf104a6ebb667565727ef0bb294a7c3197" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "nom_locate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f932834fd8e391fc7710e2ba17e8f9f8645d846b55aa63207e17e110a1e1ce35" +dependencies = [ + "bytecount 0.3.2", + "memchr", + "nom", +] + +[[package]] +name = "nom_locate" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a67484adf5711f94f2f28b653bf231bff8e438be33bf5b0f35935a0db4f618a2" +dependencies = [ + "bytecount 0.6.2", + "memchr", + "nom", ] [[package]] @@ -1457,17 +1577,26 @@ dependencies = [ "fsevent-sys", "inotify", "libc", - "mio", + "mio 0.6.23", "mio-extras", "walkdir", "winapi 0.3.9", ] [[package]] -name = "num-integer" -version = "0.1.43" +name = "ntapi" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ "autocfg", "num-traits", @@ -1475,9 +1604,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" dependencies = [ "autocfg", "num-integer", @@ -1486,9 +1615,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" dependencies = [ "autocfg", "num-integer", @@ -1497,9 +1626,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ "autocfg", ] @@ -1516,15 +1645,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.4.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "onig" -version = "6.1.0" +version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a155d13862da85473665694f4c05d77fb96598bdceeaf696433c84ea9567e20" +checksum = "30b46fd9edbc018f0be4e366c24c46db44fac49cd01c039ae85308088b089dd5" dependencies = [ "bitflags", "lazy_static", @@ -1534,9 +1663,9 @@ dependencies = [ [[package]] name = "onig_sys" -version = "69.5.1" +version = "69.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bff06597a6b17855040955cae613af000fc0bfc8ad49ea68b9479a74e59292d" +checksum = "ed063c96cf4c0f2e5d09324409d158b38a0a85a7b90fbd68c8cad75c495d5775" dependencies = [ "cc", "pkg-config", @@ -1647,7 +1776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ "phf_shared", - "rand", + "rand 0.7.3", ] [[package]] @@ -1661,18 +1790,38 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.24" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f48fad7cfbff853437be7cf54d7b993af21f53be7f0988cbfe4a51535aa77205" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" dependencies = [ - "pin-project-internal", + "pin-project-internal 0.4.27", +] + +[[package]] +name = "pin-project" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a83804639aad6ba65345661744708855f9fbcb71176ea8d28d05aeb11d975e7" +dependencies = [ + "pin-project-internal 1.0.3", ] [[package]] name = "pin-project-internal" -version = "0.4.24" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24c6d293bdd3ca5a1697997854c6cf7855e43fb6a0ba1c47af57a5bcafd158ae" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7bcc46b8f73443d15bc1c5fecbb315718491fa9187fa483f0e359323cde8b3a" dependencies = [ "proc-macro2", "quote", @@ -1681,9 +1830,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.8" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f349a4f0e70676ffb2dbafe16d0c992382d02f0a952e3ddf584fc289dac6b3" +checksum = "6196deb704a4cebec440b7a50d05d55410be7c923caf0447f9d052508b8dca3c" [[package]] name = "pin-utils" @@ -1693,15 +1842,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "plist" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b336d94e8e4ce29bf15bba393164629764744c567e8ad306cc1fdd0119967fd" +checksum = "4dc57ccf442c7414b790e8e7b72fb4d776a66c7680129360946d9aaa6f5311e9" dependencies = [ "base64", "chrono", @@ -1713,9 +1862,9 @@ dependencies = [ [[package]] name = "png" -version = "0.16.7" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970" +checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" dependencies = [ "bitflags", "crc32fast", @@ -1725,9 +1874,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "precomputed-hash" @@ -1761,9 +1910,9 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.18" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" @@ -1773,9 +1922,9 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" [[package]] name = "proc-macro2" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] @@ -1792,10 +1941,16 @@ dependencies = [ ] [[package]] -name = "quote" -version = "1.0.7" +name = "quick-error" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -1806,14 +1961,26 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", "rand_pcg", ] +[[package]] +name = "rand" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c24fcd450d3fa2b592732565aa4f17a27a61c65ece4726353e000939b0edee34" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.1", + "rand_hc 0.3.0", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -1821,7 +1988,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.1", ] [[package]] @@ -1830,7 +2007,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" +dependencies = [ + "getrandom 0.2.1", ] [[package]] @@ -1839,7 +2025,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.1", ] [[package]] @@ -1848,14 +2043,14 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] name = "rayon" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd016f0c045ad38b5251be2c9c0ab806917f82da4d36b2a327e5166adad9270" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque", @@ -1865,9 +2060,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -1884,13 +2079,13 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regex" -version = "1.3.9" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.6.18", + "regex-syntax 0.6.22", "thread_local", ] @@ -1911,9 +2106,9 @@ checksum = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" [[package]] name = "regex-syntax" -version = "0.6.18" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "relative-path" @@ -1937,6 +2132,7 @@ dependencies = [ "config", "errors", "front_matter", + "gh-emoji", "lazy_static", "link_checker", "pest", @@ -1953,12 +2149,12 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.10.8" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" +checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de" dependencies = [ "base64", - "bytes 0.5.6", + "bytes 1.0.0", "encoding_rs", "futures-core", "futures-util", @@ -1971,12 +2167,11 @@ dependencies = [ "lazy_static", "log", "mime", - "mime_guess", "percent-encoding", "pin-project-lite", "rustls", "serde", - "serde_urlencoded", + "serde_urlencoded 0.7.0", "tokio", "tokio-rustls", "url", @@ -1989,9 +2184,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.15" +version = "0.16.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" +checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" dependencies = [ "cc", "libc", @@ -2004,9 +2199,9 @@ dependencies = [ [[package]] name = "roxmltree" -version = "0.11.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5001f134077069d87f77c8b9452b690df2445f7a43f1c7ca4a1af8dd505789d" +checksum = "dbf7d7b1ea646d380d0e8153158063a6da7efe30ddbf3184042848e3f8a6f671" dependencies = [ "xmlparser", ] @@ -2023,9 +2218,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" +checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" dependencies = [ "base64", "log", @@ -2113,18 +2308,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.116" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.116" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2", "quote", @@ -2133,9 +2328,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.57" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "indexmap", "itoa", @@ -2155,6 +2350,30 @@ dependencies = [ "url", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "971be8f6e4d4a47163b405a3df70d14359186f9ab0f3a3ec37df144ca1ce089f" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + [[package]] name = "sha-1" version = "0.8.2" @@ -2169,12 +2388,12 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" +checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ "block-buffer 0.9.0", - "cfg-if", + "cfg-if 1.0.0", "cpuid-bool", "digest 0.9.0", "opaque-debug 0.3.0", @@ -2198,17 +2417,18 @@ dependencies = [ "lazy_static", "library", "link_checker", - "minify-html", "rayon", "relative-path", "sass-rs", "search", "serde", "serde_derive", + "slotmap", "tempfile", "templates", "tera", "utils", + "walkdir", ] [[package]] @@ -2234,19 +2454,18 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.4.2" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.3.15" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] @@ -2257,10 +2476,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] -name = "string_cache" -version = "0.8.0" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2940c75beb4e3bf3a494cef919a747a2cb81e52571e212bfbd185074add7208a" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_cache" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" dependencies = [ "lazy_static", "new_debug_unreachable", @@ -2307,9 +2532,9 @@ dependencies = [ [[package]] name = "svg_metadata" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe5b1fbd62339f055704951dcaf2e757c460b9f6abe17f6de0d2563da821c57" +checksum = "d39f36262efe61096a17aa42140b0e44b9189806c3fa71ab3cff123429938eb0" dependencies = [ "doc-comment", "lazy_static", @@ -2319,9 +2544,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.42" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" +checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" dependencies = [ "proc-macro2", "quote", @@ -2330,9 +2555,9 @@ dependencies = [ [[package]] name = "syntect" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3978df05b5850c839a6b352d3c35ce0478944a4be689be826b53cf75363e88" +checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5" dependencies = [ "bincode", "bitflags", @@ -2342,7 +2567,7 @@ dependencies = [ "lazycell", "onig", "plist", - "regex-syntax 0.6.18", + "regex-syntax 0.6.22", "serde", "serde_derive", "serde_json", @@ -2356,9 +2581,9 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", - "rand", + "rand 0.7.3", "redox_syscall", "remove_dir_all", "winapi 0.3.9", @@ -2377,7 +2602,8 @@ dependencies = [ "lazy_static", "library", "mockito", - "pulldown-cmark", + "nom-bibtex", + "rendering", "reqwest", "serde_json", "sha2", @@ -2390,9 +2616,9 @@ dependencies = [ [[package]] name = "tendril" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b" +checksum = "a9ef557cb397a4f0a5a3a628f06515f78563f2209e64d47055d9dc6052bf5e33" dependencies = [ "futf", "mac", @@ -2401,9 +2627,9 @@ dependencies = [ [[package]] name = "tera" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1381c83828bedd5ce4e59473110afa5381ffe523406d9ade4b77c9f7be70ff9a" +checksum = "eac6ab7eacf40937241959d540670f06209c38ceadb62116999db4a950fbf8dc" dependencies = [ "chrono", "chrono-tz", @@ -2413,7 +2639,7 @@ dependencies = [ "percent-encoding", "pest", "pest_derive", - "rand", + "rand 0.8.1", "regex", "serde", "serde_json", @@ -2423,13 +2649,25 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] +[[package]] +name = "test-case" +version = "1.0.0" +source = "git+https://github.com/frondeus/test-case#65b6fb60c69054950a149b64a0a9f042c0e4fd59" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "syn", + "version_check", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -2441,102 +2679,106 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" dependencies = [ "lazy_static", ] [[package]] name = "tiff" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b8a87c4da944c3f27e5943289171ac71a6150a79ff6bacfff06d159dfff2f" +checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" dependencies = [ - "byteorder", - "lzw", - "miniz_oxide 0.3.7", + "jpeg-decoder", + "miniz_oxide 0.4.3", + "weezl", ] [[package]] name = "time" -version = "0.1.44" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] [[package]] name = "tinyvec" -version = "0.3.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" - -[[package]] -name = "tokio" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" dependencies = [ - "bytes 0.5.6", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "memchr", - "mio", - "num_cpus", - "pin-project-lite", - "slab", - "tokio-macros", + "tinyvec_macros", ] [[package]] -name = "tokio-macros" -version = "0.2.5" +name = "tinyvec_macros" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d258221f566b6c803c7b4714abadc080172b272090cdc5e244a6d4dd13c3a6bd" dependencies = [ - "proc-macro2", - "quote", - "syn", + "autocfg", + "bytes 1.0.0", + "libc", + "memchr", + "mio 0.7.7", + "num_cpus", + "pin-project-lite", ] [[package]] name = "tokio-rustls" -version = "0.14.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ - "futures-core", "rustls", "tokio", "webpki", ] [[package]] -name = "tokio-util" -version = "0.3.1" +name = "tokio-stream" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +checksum = "e4cdeb73537e63f98adcd73138af75e3f368ccaecffaa29d7eb61b9f5a440457" dependencies = [ - "bytes 0.5.6", "futures-core", - "futures-sink", - "log", "pin-project-lite", "tokio", ] [[package]] -name = "toml" -version = "0.5.6" +name = "tokio-util" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "36135b7e7da911f5f8b9331209f7fab4cc13498f3fff52f72a710c78187e3148" +dependencies = [ + "bytes 1.0.0", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", + "tokio-stream", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] @@ -2549,24 +2791,34 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" [[package]] name = "tracing" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", + "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bcf46c1f1f06aeea2d6b81f3c863d0930a596c86ad1920d4e5bad6dd1d7119a" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-futures" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +dependencies = [ + "pin-project 0.4.27", + "tracing", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -2655,18 +2907,18 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.13" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" @@ -2688,10 +2940,11 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" dependencies = [ + "form_urlencoded", "idna", "matches", "percent-encoding", @@ -2715,6 +2968,7 @@ version = "0.1.0" dependencies = [ "errors", "filetime", + "minify-html", "percent-encoding", "serde", "serde_derive", @@ -2738,12 +2992,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "walkdir" version = "2.3.1" @@ -2773,17 +3021,17 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" [[package]] name = "wasm-bindgen" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" +checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "serde", "serde_json", "wasm-bindgen-macro", @@ -2791,9 +3039,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" +checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" dependencies = [ "bumpalo", "lazy_static", @@ -2806,11 +3054,11 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" +checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -2818,9 +3066,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" +checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2828,9 +3076,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" +checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" dependencies = [ "proc-macro2", "quote", @@ -2841,15 +3089,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" +checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" [[package]] name = "web-sys" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" +checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" dependencies = [ "js-sys", "wasm-bindgen", @@ -2857,9 +3105,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ "ring", "untrusted", @@ -2867,18 +3115,18 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" +checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376" dependencies = [ "webpki", ] [[package]] name = "weezl" -version = "0.1.0" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d2f24b6c3aa92fb33279566dbebf1cbe66b03a73f09aa69cf8cf14d2f9feb9" +checksum = "3e2bb9fc8309084dd7cd651336673844c1d47f8ef6d2091ec160b27f5c4aa277" [[package]] name = "winapi" @@ -2942,9 +3190,9 @@ dependencies = [ "bytes 0.4.12", "httparse", "log", - "mio", + "mio 0.6.23", "mio-extras", - "rand", + "rand 0.7.3", "sha-1", "slab", "url", @@ -2986,16 +3234,16 @@ checksum = "114ba2b24d2167ef6d67d7d04c8cc86522b87f490025f39f0303b7db5bf5e3d8" [[package]] name = "yaml-rust" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] [[package]] name = "zola" -version = "0.12.2" +version = "0.13.0" dependencies = [ "atty", "chrono", @@ -3005,11 +3253,12 @@ dependencies = [ "front_matter", "globset", "hyper", - "hyper-staticfile", "lazy_static", "notify", "open", + "percent-encoding", "relative-path", + "serde_json", "site", "termcolor", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 2f475f63..5445f5c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zola" -version = "0.12.2" +version = "0.13.0" authors = ["Vincent Prouillet "] edition = "2018" license = "MIT" @@ -27,15 +27,16 @@ termcolor = "1.0.4" # Used in init to ensure the url given as base_url is a valid one url = "2" # Below is for the serve cmd -hyper = { version = "0.13", default-features = false, features = ["runtime"] } -hyper-staticfile = "0.5" -tokio = { version = "0.2", default-features = false, features = [] } +hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] } +tokio = { version = "1.0.1", default-features = false, features = ["rt", "fs"] } +percent-encoding = "2" notify = "4" ws = "0.9" ctrlc = "3" open = "1.2" globset = "0.4" relative-path = "1" +serde_json = "1.0" site = { path = "components/site" } errors = { path = "components/errors" } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 86df2772..a43732b4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,7 +21,7 @@ stages: rustup_toolchain: stable linux-pinned: imageName: 'ubuntu-20.04' - rustup_toolchain: 1.43.0 + rustup_toolchain: 1.45.2 pool: vmImage: $(imageName) steps: diff --git a/components/config/examples/generate_sublime.rs b/components/config/examples/generate_sublime.rs index f47bff13..fb859349 100644 --- a/components/config/examples/generate_sublime.rs +++ b/components/config/examples/generate_sublime.rs @@ -7,6 +7,7 @@ use std::collections::HashMap; use std::collections::HashSet; use std::env; use std::iter::FromIterator; +use std::path::Path; use syntect::dumps::*; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSetBuilder; @@ -26,10 +27,24 @@ fn main() { (Some(ref cmd), Some(ref package_dir), Some(ref packpath_newlines)) if cmd == "synpack" => { let mut builder = SyntaxSetBuilder::new(); builder.add_plain_text_syntax(); - match builder.add_from_folder(package_dir, true) { + let base_path = Path::new(&package_dir).to_path_buf(); + + // First the official Sublime packages + let mut default = base_path.clone(); + default.push("Packages"); + match builder.add_from_folder(&default, true) { Ok(_) => (), Err(e) => println!("Loading error: {:?}", e), }; + + // and then the ones we add + let mut extra = base_path.clone(); + extra.push("extra"); + match builder.add_from_folder(&extra, true) { + Ok(_) => (), + Err(e) => println!("Loading error: {:?}", e), + }; + let ss = builder.build(); dump_to_file(&ss, packpath_newlines).unwrap(); let mut syntaxes: HashMap> = HashMap::new(); diff --git a/components/config/src/config/markup.rs b/components/config/src/config/markup.rs new file mode 100644 index 00000000..3feb5cfc --- /dev/null +++ b/components/config/src/config/markup.rs @@ -0,0 +1,80 @@ +use serde_derive::{Deserialize, Serialize}; +use syntect::parsing::SyntaxSet; + +pub const DEFAULT_HIGHLIGHT_THEME: &str = "base16-ocean-dark"; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(default)] +pub struct Markdown { + /// 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 render emoji aliases (e.g.: :smile: => 😄) in the markdown files + pub render_emoji: bool, + /// Whether external links are to be opened in a new tab + /// If this is true, a `rel="noopener"` will always automatically be added for security reasons + pub external_links_target_blank: bool, + /// Whether to set rel="nofollow" for all external links + pub external_links_no_follow: bool, + /// Whether to set rel="noreferrer" for all external links + pub external_links_no_referrer: bool, + /// Whether smart punctuation is enabled (changing quotes, dashes, dots etc in their typographic form) + pub smart_punctuation: 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, +} + +impl Markdown { + pub fn has_external_link_tweaks(&self) -> bool { + self.external_links_target_blank + || self.external_links_no_follow + || self.external_links_no_referrer + } + + pub fn construct_external_link_tag(&self, url: &str, title: &str) -> String { + let mut rel_opts = Vec::new(); + let mut target = "".to_owned(); + let title = if title == "" { "".to_owned() } else { format!("title=\"{}\" ", title) }; + + if self.external_links_target_blank { + // Security risk otherwise + rel_opts.push("noopener"); + target = "target=\"_blank\" ".to_owned(); + } + if self.external_links_no_follow { + rel_opts.push("nofollow"); + } + if self.external_links_no_referrer { + rel_opts.push("noreferrer"); + } + let rel = if rel_opts.is_empty() { + "".to_owned() + } else { + format!("rel=\"{}\" ", rel_opts.join(" ")) + }; + + format!("", rel, target, title, url) + } +} + +impl Default for Markdown { + fn default() -> Markdown { + Markdown { + highlight_code: false, + highlight_theme: DEFAULT_HIGHLIGHT_THEME.to_owned(), + render_emoji: false, + external_links_target_blank: false, + external_links_no_follow: false, + external_links_no_referrer: false, + smart_punctuation: false, + extra_syntaxes: vec![], + extra_syntax_set: None, + } + } +} diff --git a/components/config/src/config/mod.rs b/components/config/src/config/mod.rs index a23e3825..415f215b 100644 --- a/components/config/src/config/mod.rs +++ b/components/config/src/config/mod.rs @@ -1,5 +1,6 @@ pub mod languages; pub mod link_checker; +pub mod markup; pub mod search; pub mod slugify; pub mod taxonomies; @@ -9,7 +10,7 @@ use std::path::{Path, PathBuf}; use globset::{Glob, GlobSet, GlobSetBuilder}; use serde_derive::{Deserialize, Serialize}; -use syntect::parsing::{SyntaxSet, SyntaxSetBuilder}; +use syntect::parsing::SyntaxSetBuilder; use toml::Value as Toml; use crate::highlighting::THEME_SET; @@ -55,10 +56,10 @@ pub struct Config { translations: HashMap, /// Whether to highlight all code blocks found in markdown files. Defaults to false - pub highlight_code: bool, + highlight_code: bool, /// Which themes to use for code highlighting. See Readme for supported themes /// Defaults to "base16-ocean-dark" - pub highlight_theme: String, + highlight_theme: String, /// Whether to generate a feed. Defaults to false. pub generate_feed: bool, @@ -92,9 +93,8 @@ pub struct Config { /// 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, + + pub output_dir: String, pub link_checker: link_checker::LinkChecker, @@ -104,6 +104,9 @@ pub struct Config { /// The search config, telling what to include in the search index pub search: search::Search, + /// The config for the Markdown rendering: syntax highlighting and everything + pub markdown: markup::Markdown, + /// All user params set in [extra] in the config pub extra: HashMap, } @@ -153,8 +156,12 @@ impl Config { } } - // TODO: re-enable once it's a bit more tested - config.minify_html = false; + if config.highlight_code { + println!("`highlight_code` has been moved to a [markdown] section. Top level `highlight_code` and `highlight_theme` will stop working in 0.14."); + } + if !config.extra_syntaxes.is_empty() { + println!("`extra_syntaxes` has been moved to a [markdown] section. Top level `extra_syntaxes` will stop working in 0.14."); + } Ok(config) } @@ -170,17 +177,56 @@ impl Config { Config::parse(&content) } + /// Temporary, while we have the settings in 2 places + /// TODO: remove me in 0.14 + pub fn highlight_code(&self) -> bool { + if !self.highlight_code && !self.markdown.highlight_code { + return false; + } + + if self.highlight_code { + true + } else { + self.markdown.highlight_code + } + } + + /// Temporary, while we have the settings in 2 places + /// TODO: remove me in 0.14 + pub fn highlight_theme(&self) -> &str { + if self.highlight_theme != markup::DEFAULT_HIGHLIGHT_THEME { + &self.highlight_theme + } else { + &self.markdown.highlight_theme + } + } + + /// TODO: remove me in 0.14 + pub fn extra_syntaxes(&self) -> Vec { + if !self.markdown.extra_syntaxes.is_empty() { + return self.markdown.extra_syntaxes.clone(); + } + + if !self.extra_syntaxes.is_empty() { + return self.extra_syntaxes.clone(); + } + + Vec::new() + } + /// Attempt to load any extra syntax found in the extra syntaxes of the config + /// TODO: move to markup.rs in 0.14 pub fn load_extra_syntaxes(&mut self, base_path: &Path) -> Result<()> { - if self.extra_syntaxes.is_empty() { + let extra_syntaxes = self.extra_syntaxes(); + if extra_syntaxes.is_empty() { return Ok(()); } let mut ss = SyntaxSetBuilder::new(); - for dir in &self.extra_syntaxes { + for dir in &extra_syntaxes { ss.add_from_folder(base_path.join(dir), true)?; } - self.extra_syntax_set = Some(ss.build()); + self.markdown.extra_syntax_set = Some(ss.build()); Ok(()) } @@ -332,10 +378,11 @@ impl Default for Config { ignored_content_globset: None, translations: HashMap::new(), extra_syntaxes: Vec::new(), - extra_syntax_set: None, + output_dir: "public".to_string(), link_checker: link_checker::LinkChecker::default(), slugify: slugify::Slugify::default(), search: search::Search::default(), + markdown: markup::Markdown::default(), extra: HashMap::new(), } } @@ -654,4 +701,27 @@ bar = "baz" // We expect an error here assert_eq!(false, config.add_theme_extra(&theme).is_ok()); } + + #[test] + fn default_output_dir() { + let config = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com" + "#; + + let config = Config::parse(config).unwrap(); + assert_eq!(config.output_dir, "public".to_string()); + } + + #[test] + fn can_add_output_dir() { + let config = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com" +output_dir = "docs" + "#; + + let config = Config::parse(config).unwrap(); + assert_eq!(config.output_dir, "docs".to_string()); + } } diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs index 8b3d8d50..2d733d10 100644 --- a/components/config/src/highlighting.rs +++ b/components/config/src/highlighting.rs @@ -18,24 +18,25 @@ lazy_static! { /// Returns the highlighter and whether it was found in the extra or not pub fn get_highlighter(language: Option<&str>, config: &Config) -> (HighlightLines<'static>, bool) { - let theme = &THEME_SET.themes[&config.highlight_theme]; + let theme = &THEME_SET.themes[config.highlight_theme()]; let mut in_extra = false; if let Some(ref lang) = language { - 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()); + let syntax = if let Some(ref extra) = config.markdown.extra_syntax_set { + let s = extra.find_syntax_by_token(lang); + if s.is_some() { + in_extra = true; + } + s + } else { + // The JS syntax hangs a lot... the TS syntax is probably better anyway. + // https://github.com/getzola/zola/issues/1241 + // https://github.com/getzola/zola/issues/1211 + // https://github.com/getzola/zola/issues/1174 + let hacked_lang = if *lang == "js" || *lang == "javascript" { "ts" } else { lang }; + SYNTAX_SET.find_syntax_by_token(hacked_lang) + } + .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/errors/src/lib.rs b/components/errors/src/lib.rs index 037c48df..dcaee80f 100644 --- a/components/errors/src/lib.rs +++ b/components/errors/src/lib.rs @@ -57,7 +57,7 @@ impl Error { } /// Create an error from a list of path collisions, formatting the output - pub fn from_collisions(collisions: Vec<(&str, Vec)>) -> Self { + pub fn from_collisions(collisions: Vec<(String, Vec)>) -> Self { let mut msg = String::from("Found path collisions:\n"); for (path, filepaths) in collisions { diff --git a/components/front_matter/Cargo.toml b/components/front_matter/Cargo.toml index eb3f8a6f..c46d3b11 100644 --- a/components/front_matter/Cargo.toml +++ b/components/front_matter/Cargo.toml @@ -9,9 +9,17 @@ tera = "1" chrono = "0.4" serde = "1" serde_derive = "1" +serde_yaml = "0.8" toml = "0.5" regex = "1" lazy_static = "1" errors = { path = "../errors" } utils = { path = "../utils" } + +[dev-dependencies] +# Remove from git patch when 1.0.1 is released +# https://github.com/frondeus/test-case/issues/62 +# test-case = "1.0" +test-case = { git = "https://github.com/frondeus/test-case" } + diff --git a/components/front_matter/src/lib.rs b/components/front_matter/src/lib.rs index f0866797..834747b3 100644 --- a/components/front_matter/src/lib.rs +++ b/components/front_matter/src/lib.rs @@ -3,7 +3,9 @@ use serde_derive::{Deserialize, Serialize}; use errors::{bail, Error, Result}; use regex::Regex; +use serde_yaml; use std::path::Path; +use toml; mod page; mod section; @@ -12,8 +14,31 @@ pub use page::PageFrontMatter; pub use section::SectionFrontMatter; lazy_static! { - static ref PAGE_RE: Regex = + static ref TOML_RE: Regex = Regex::new(r"^[[:space:]]*\+\+\+(\r?\n(?s).*?(?-s))\+\+\+\r?\n?((?s).*(?-s))$").unwrap(); + static ref YAML_RE: Regex = + Regex::new(r"^[[:space:]]*---(\r?\n(?s).*?(?-s))---\r?\n?((?s).*(?-s))$").unwrap(); +} + +pub enum RawFrontMatter<'a> { + Toml(&'a str), + Yaml(&'a str), +} + +impl RawFrontMatter<'_> { + fn deserialize(&self) -> Result + where + T: serde::de::DeserializeOwned, + { + let f: T = match self { + RawFrontMatter::Toml(s) => toml::from_str(s)?, + RawFrontMatter::Yaml(s) => match serde_yaml::from_str(s) { + Ok(d) => d, + Err(e) => bail!(format!("YAML deserialize error: {:?}", e)), + }, + }; + Ok(f) + } } #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] @@ -37,20 +62,30 @@ pub enum InsertAnchor { /// Split a file between the front matter and its content /// Will return an error if the front matter wasn't found -fn split_content<'c>(file_path: &Path, content: &'c str) -> Result<(&'c str, &'c str)> { - if !PAGE_RE.is_match(content) { +fn split_content<'c>(file_path: &Path, content: &'c str) -> Result<(RawFrontMatter<'c>, &'c str)> { + let (re, is_toml) = if TOML_RE.is_match(content) { + (&TOML_RE as &Regex, true) + } else if YAML_RE.is_match(content) { + (&YAML_RE as &Regex, false) + } else { bail!( - "Couldn't find front matter in `{}`. Did you forget to add `+++`?", + "Couldn't find front matter in `{}`. Did you forget to add `+++` or `---`?", file_path.to_string_lossy() ); - } + }; // 2. extract the front matter and the content - let caps = PAGE_RE.captures(content).unwrap(); + let caps = re.captures(content).unwrap(); // caps[0] is the full match // caps[1] => front matter // caps[2] => content - Ok((caps.get(1).unwrap().as_str(), caps.get(2).unwrap().as_str())) + let front_matter = caps.get(1).unwrap().as_str(); + let content = caps.get(2).unwrap().as_str(); + if is_toml { + Ok((RawFrontMatter::Toml(front_matter), content)) + } else { + Ok((RawFrontMatter::Yaml(front_matter), content)) + } } /// Split a file between the front matter and its content. @@ -88,71 +123,125 @@ pub fn split_page_content<'c>( #[cfg(test)] mod tests { use std::path::Path; + use test_case::test_case; use super::{split_page_content, split_section_content}; - #[test] - fn can_split_page_content_valid() { - let content = r#" + #[test_case(r#" +++ title = "Title" description = "hey there" date = 2002-10-12 +++ Hello -"#; +"#; "toml")] + #[test_case(r#" +--- +title: Title +description: hey there +date: 2002-10-12 +--- +Hello +"#; "yaml")] + fn can_split_page_content_valid(content: &str) { let (front_matter, content) = split_page_content(Path::new(""), content).unwrap(); assert_eq!(content, "Hello\n"); assert_eq!(front_matter.title.unwrap(), "Title"); } - #[test] - fn can_split_section_content_valid() { - let content = r#" + #[test_case(r#" +++ paginate_by = 10 +++ Hello -"#; +"#; "toml")] + #[test_case(r#" +--- +paginate_by: 10 +--- +Hello +"#; "yaml")] + fn can_split_section_content_valid(content: &str) { let (front_matter, content) = split_section_content(Path::new(""), content).unwrap(); assert_eq!(content, "Hello\n"); assert!(front_matter.is_paginated()); } - #[test] - fn can_split_content_with_only_frontmatter_valid() { - let content = r#" + #[test_case(r#" +++ title = "Title" description = "hey there" date = 2002-10-12 -+++"#; ++++"#; "toml")] + #[test_case(r#" +--- +title: Title +description: hey there +date: 2002-10-12 +---"#; "yaml")] + fn can_split_content_with_only_frontmatter_valid(content: &str) { let (front_matter, content) = split_page_content(Path::new(""), content).unwrap(); assert_eq!(content, ""); assert_eq!(front_matter.title.unwrap(), "Title"); } - #[test] - fn can_split_content_lazily() { - let content = r#" + #[test_case(r#" +++ title = "Title" description = "hey there" date = 2002-10-02T15:00:00Z +++ -+++"#; - let (front_matter, content) = split_page_content(Path::new(""), content).unwrap(); - assert_eq!(content, "+++"); - assert_eq!(front_matter.title.unwrap(), "Title"); - } - - #[test] - fn errors_if_cannot_locate_frontmatter() { - let content = r#" ++++"#, "+++"; "toml with pluses in content")] + #[test_case(r#" +++ title = "Title" description = "hey there" -date = 2002-10-12"#; +date = 2002-10-02T15:00:00Z ++++ +---"#, "---"; "toml with minuses in content")] + #[test_case(r#" +--- +title: Title +description: hey there +date: 2002-10-02T15:00:00Z +--- ++++"#, "+++"; "yaml with pluses in content")] + #[test_case(r#" +--- +title: Title +description: hey there +date: 2002-10-02T15:00:00Z +--- +---"#, "---"; "yaml with minuses in content")] + fn can_split_content_lazily(content: &str, expected: &str) { + let (front_matter, content) = split_page_content(Path::new(""), content).unwrap(); + assert_eq!(content, expected); + assert_eq!(front_matter.title.unwrap(), "Title"); + } + + #[test_case(r#" ++++ +title = "Title" +description = "hey there" +date = 2002-10-12"#; "toml")] + #[test_case(r#" ++++ +title = "Title" +description = "hey there" +date = 2002-10-12 +---"#; "toml unmatched")] + #[test_case(r#" +--- +title: Title +description: hey there +date: 2002-10-12"#; "yaml")] + #[test_case(r#" +--- +title: Title +description: hey there +date: 2002-10-12 ++++"#; "yaml unmatched")] + fn errors_if_cannot_locate_frontmatter(content: &str) { let res = split_page_content(Path::new(""), content); assert!(res.is_err()); } diff --git a/components/front_matter/src/page.rs b/components/front_matter/src/page.rs index f38f1a2e..da39a5e7 100644 --- a/components/front_matter/src/page.rs +++ b/components/front_matter/src/page.rs @@ -7,6 +7,8 @@ use tera::{Map, Value}; use errors::{bail, Result}; use utils::de::{fix_toml_dates, from_toml_datetime}; +use crate::RawFrontMatter; + /// The front matter of every page #[derive(Debug, Clone, PartialEq, Deserialize)] #[serde(default)] @@ -69,11 +71,8 @@ fn parse_datetime(d: &str) -> Option { } impl PageFrontMatter { - pub fn parse(toml: &str) -> Result { - let mut f: PageFrontMatter = match toml::from_str(toml) { - Ok(d) => d, - Err(e) => bail!(e), - }; + pub fn parse(raw: &RawFrontMatter) -> Result { + let mut f: PageFrontMatter = raw.deserialize()?; if let Some(ref slug) = f.slug { if slug == "" { @@ -140,21 +139,27 @@ impl Default for PageFrontMatter { #[cfg(test)] mod tests { use super::PageFrontMatter; + use super::RawFrontMatter; use tera::to_value; + use test_case::test_case; - #[test] - fn can_have_empty_front_matter() { - let content = r#" "#; + #[test_case(&RawFrontMatter::Toml(r#" "#); "toml")] + #[test_case(&RawFrontMatter::Toml(r#" "#); "yaml")] + fn can_have_empty_front_matter(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); } - #[test] - fn can_parse_valid_front_matter() { - let content = r#" - title = "Hello" - description = "hey there""#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +"#); "yaml")] + fn can_parse_valid_front_matter(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_ok()); let res = res.unwrap(); @@ -162,183 +167,281 @@ mod tests { assert_eq!(res.description.unwrap(), "hey there".to_string()) } - #[test] - fn errors_with_invalid_front_matter() { - let content = r#"title = 1\n"#; + #[test_case(&RawFrontMatter::Toml(r#"title = |\n"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#"title: |\n"#); "yaml")] + fn errors_with_invalid_front_matter(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_err()); } - #[test] - fn errors_on_present_but_empty_slug() { - let content = r#" - title = "Hello" - description = "hey there" - slug = """#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +slug = "" +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +slug: "" +"#); "yaml")] + fn errors_on_present_but_empty_slug(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_err()); } - #[test] - fn errors_on_present_but_empty_path() { - let content = r#" - title = "Hello" - description = "hey there" - path = """#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +path = "" +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +path: "" +"#); "yaml")] + fn errors_on_present_but_empty_path(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_err()); } - #[test] - fn can_parse_date_yyyy_mm_dd() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2016-10-10 - "#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2016-10-10 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2016-10-10 +"#); "yaml")] + fn can_parse_date_yyyy_mm_dd(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content).unwrap(); assert!(res.datetime.is_some()); } - #[test] - fn can_parse_date_rfc3339() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002-10-02T15:00:00Z - "#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002-10-02T15:00:00Z +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002-10-02T15:00:00Z +"#); "yaml")] + fn can_parse_date_rfc3339(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content).unwrap(); assert!(res.datetime.is_some()); } - #[test] - fn can_parse_date_rfc3339_without_timezone() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002-10-02T15:00:00 - "#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002-10-02T15:00:00 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002-10-02T15:00:00 +"#); "yaml")] + fn can_parse_date_rfc3339_without_timezone(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content).unwrap(); assert!(res.datetime.is_some()); } - #[test] - fn can_parse_date_rfc3339_with_space() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002-10-02 15:00:00+02:00 - "#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002-10-02 15:00:00+02:00 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002-10-02 15:00:00+02:00 +"#); "yaml")] + fn can_parse_date_rfc3339_with_space(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content).unwrap(); assert!(res.datetime.is_some()); } - #[test] - fn can_parse_date_rfc3339_with_space_without_timezone() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002-10-02 15:00:00 - "#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002-10-02 15:00:00 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002-10-02 15:00:00 +"#); "yaml")] + fn can_parse_date_rfc3339_with_space_without_timezone(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content).unwrap(); assert!(res.datetime.is_some()); } - #[test] - fn can_parse_date_rfc3339_with_microseconds() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002-10-02T15:00:00.123456Z - "#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002-10-02T15:00:00.123456Z +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002-10-02T15:00:00.123456Z +"#); "yaml")] + fn can_parse_date_rfc3339_with_microseconds(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content).unwrap(); assert!(res.datetime.is_some()); } - #[test] - fn cannot_parse_random_date_format() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002/10/12"#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002/10/12 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002/10/12 +"#); "yaml")] + fn cannot_parse_random_date_format(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_err()); } - #[test] - fn cannot_parse_invalid_date_format() { - let content = r#" - title = "Hello" - description = "hey there" - date = 2002-14-01"#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = 2002-14-01 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: 2002-14-01 +"#); "yaml")] + fn cannot_parse_invalid_date_format(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_err()); } - #[test] - fn cannot_parse_date_as_string() { - let content = r#" - title = "Hello" - description = "hey there" - date = "2002-14-01""#; + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = "2016-10-10" +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: "2016-10-10" +"#); "yaml")] + fn can_parse_valid_date_as_string(content: &RawFrontMatter) { + let res = PageFrontMatter::parse(content).unwrap(); + assert!(res.date.is_some()); + } + + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" +date = "2002-14-01" +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there +date: "2002-14-01" +"#); "yaml")] + fn cannot_parse_invalid_date_as_string(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); assert!(res.is_err()); } - #[test] - fn can_parse_dates_in_extra() { - let content = r#" - title = "Hello" - description = "hey there" + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" - [extra] - some-date = 2002-14-01"#; +[extra] +some-date = 2002-14-01 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there + +extra: + some-date: 2002-14-01 +"#); "yaml")] + fn can_parse_dates_in_extra(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); assert_eq!(res.unwrap().extra["some-date"], to_value("2002-14-01").unwrap()); } - #[test] - fn can_parse_nested_dates_in_extra() { - let content = r#" - title = "Hello" - description = "hey there" + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" - [extra.something] - some-date = 2002-14-01"#; +[extra.something] +some-date = 2002-14-01 +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there + +extra: + something: + some-date: 2002-14-01 +"#); "yaml")] + fn can_parse_nested_dates_in_extra(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); assert_eq!(res.unwrap().extra["something"]["some-date"], to_value("2002-14-01").unwrap()); } - #[test] - fn can_parse_fully_nested_dates_in_extra() { - let content = r#" - title = "Hello" - description = "hey there" + #[test_case(&RawFrontMatter::Toml(r#" +title = "Hello" +description = "hey there" - [extra] - date_example = 2020-05-04 - [[extra.questions]] - date = 2020-05-03 - name = "Who is the prime minister of Uganda?""#; +[extra] +date_example = 2020-05-04 +[[extra.questions]] +date = 2020-05-03 +name = "Who is the prime minister of Uganda?" +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello +description: hey there + +extra: + date_example: 2020-05-04 + questions: + - date: 2020-05-03 + name: "Who is the prime minister of Uganda?" +"#); "yaml")] + fn can_parse_fully_nested_dates_in_extra(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); assert_eq!(res.unwrap().extra["questions"][0]["date"], to_value("2020-05-03").unwrap()); } - #[test] - fn can_parse_taxonomies() { - let content = r#" + #[test_case(&RawFrontMatter::Toml(r#" title = "Hello World" [taxonomies] tags = ["Rust", "JavaScript"] categories = ["Dev"] -"#; +"#); "toml")] + #[test_case(&RawFrontMatter::Yaml(r#" +title: Hello World + +taxonomies: + tags: + - Rust + - JavaScript + categories: + - Dev +"#); "yaml")] + fn can_parse_taxonomies(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); diff --git a/components/front_matter/src/section.rs b/components/front_matter/src/section.rs index 365dd524..063ba014 100644 --- a/components/front_matter/src/section.rs +++ b/components/front_matter/src/section.rs @@ -2,9 +2,11 @@ use serde_derive::{Deserialize, Serialize}; use tera::{Map, Value}; use super::{InsertAnchor, SortBy}; -use errors::{bail, Result}; +use errors::Result; use utils::de::fix_toml_dates; +use crate::RawFrontMatter; + static DEFAULT_PAGINATE_PATH: &str = "page"; /// The front matter of every section @@ -22,6 +24,8 @@ pub struct SectionFrontMatter { /// Higher values means it will be at the end. Defaults to `0` #[serde(skip_serializing)] pub weight: usize, + /// whether the section is a draft + pub draft: bool, /// Optional template, if we want to specify which template to render for that section #[serde(skip_serializing)] pub template: Option, @@ -71,11 +75,8 @@ pub struct SectionFrontMatter { } impl SectionFrontMatter { - pub fn parse(toml: &str) -> Result { - let mut f: SectionFrontMatter = match toml::from_str(toml) { - Ok(d) => d, - Err(e) => bail!(e), - }; + pub fn parse(raw: &RawFrontMatter) -> Result { + let mut f: SectionFrontMatter = raw.deserialize()?; f.extra = match fix_toml_dates(f.extra) { Value::Object(o) => o, @@ -114,6 +115,7 @@ impl Default for SectionFrontMatter { aliases: Vec::new(), generate_feed: false, extra: Map::new(), + draft: false, } } } diff --git a/components/library/src/content/file_info.rs b/components/library/src/content/file_info.rs index 7cae3c11..167d6048 100644 --- a/components/library/src/content/file_info.rs +++ b/components/library/src/content/file_info.rs @@ -129,6 +129,11 @@ impl FileInfo { // We can document that let mut parts: Vec = self.name.splitn(2, '.').map(|s| s.to_string()).collect(); + // If language code is same as default language, go for default + if config.default_language == parts[1].as_str() { + return Ok(config.default_language.clone()); + } + // The language code is not present in the config: typo or the user forgot to add it to the // config if !config.languages_codes().contains(&parts[1].as_ref()) { @@ -189,6 +194,19 @@ mod tests { assert_eq!(res.unwrap(), "fr"); } + #[test] + fn can_find_valid_language_with_default_locale() { + let mut config = Config::default(); + config.languages.push(Language { code: String::from("fr"), feed: false, search: false }); + let mut file = FileInfo::new_page( + &Path::new("/home/vincent/code/site/content/posts/tutorials/python.en.md"), + &PathBuf::new(), + ); + let res = file.find_language(&config); + assert!(res.is_ok()); + assert_eq!(res.unwrap(), config.default_language); + } + #[test] fn can_find_valid_language_in_page_with_assets() { let mut config = Config::default(); diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index c3c5270f..299af1a5 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -56,8 +56,6 @@ pub struct Section { /// The language of that section. Equal to the default lang if the user doesn't setup `languages` in config. /// Corresponds to the lang in the _index.{lang}.md file scheme pub lang: String, - /// Contains all the translated version of that section - pub translations: Vec, /// Contains the internal links that have an anchor: we can only check the anchor /// after all pages have been built and their ToC compiled. The page itself should exist otherwise /// it would have errored before getting there diff --git a/components/library/src/content/ser.rs b/components/library/src/content/ser.rs index 23f8aca1..1f28acd2 100644 --- a/components/library/src/content/ser.rs +++ b/components/library/src/content/ser.rs @@ -1,5 +1,6 @@ //! What we are sending to the templates when rendering them use std::collections::HashMap; +use std::collections::HashSet; use std::path::Path; use serde_derive::Serialize; @@ -24,7 +25,13 @@ impl<'a> TranslatedContent<'a> { pub fn find_all_sections(section: &'a Section, library: &'a Library) -> Vec { let mut translations = vec![]; - for key in §ion.translations { + for key in library + .translations + .get(§ion.file.canonical) + .or(Some(&HashSet::new())) + .unwrap() + .iter() + { let other = library.get_section_by_key(*key); translations.push(TranslatedContent { lang: &other.lang, @@ -40,7 +47,9 @@ impl<'a> TranslatedContent<'a> { pub fn find_all_pages(page: &'a Page, library: &'a Library) -> Vec { let mut translations = vec![]; - for key in &page.translations { + for key in + library.translations.get(&page.file.canonical).or(Some(&HashSet::new())).unwrap().iter() + { let other = library.get_page_by_key(*key); translations.push(TranslatedContent { lang: &other.lang, diff --git a/components/library/src/library.rs b/components/library/src/library.rs index 3aa7748b..d75b0aa3 100644 --- a/components/library/src/library.rs +++ b/components/library/src/library.rs @@ -41,6 +41,12 @@ pub struct Library { pub paths_to_sections: HashMap, /// Whether we need to look for translations is_multilingual: bool, + + // aliases -> files, + // so we can easily check for conflicts + pub reverse_aliases: HashMap>, + + pub translations: HashMap>, } impl Library { @@ -51,22 +57,52 @@ impl Library { paths_to_pages: HashMap::with_capacity(cap_pages), paths_to_sections: HashMap::with_capacity(cap_sections), is_multilingual, + reverse_aliases: HashMap::new(), + translations: HashMap::new(), + } + } + + fn insert_reverse_aliases(&mut self, entries: Vec, file_rel_path: &str) { + for entry in entries { + self.reverse_aliases + .entry(entry) + .and_modify(|s| { + s.insert(file_rel_path.to_owned()); + }) + .or_insert_with(|| { + let mut s = HashSet::new(); + s.insert(file_rel_path.to_owned()); + s + }); } } /// Add a section and return its Key pub fn insert_section(&mut self, section: Section) -> DefaultKey { - let path = section.file.path.clone(); + let file_path = section.file.path.clone(); + let rel_path = section.path.clone(); + + let mut entries = vec![rel_path.clone()]; + entries.extend(section.meta.aliases.iter().map(|a| a.clone()).collect::>()); + self.insert_reverse_aliases(entries, §ion.file.relative); + let key = self.sections.insert(section); - self.paths_to_sections.insert(path, key); + self.paths_to_sections.insert(file_path, key); key } /// Add a page and return its Key pub fn insert_page(&mut self, page: Page) -> DefaultKey { - let path = page.file.path.clone(); + let file_path = page.file.path.clone(); + let rel_path = page.path.clone(); + + let mut entries = vec![rel_path.clone()]; + entries.extend(page.meta.aliases.iter().map(|a| a.clone()).collect::>()); + self.insert_reverse_aliases(entries, &page.file.relative); + let key = self.pages.insert(page); - self.paths_to_pages.insert(path, key); + + self.paths_to_pages.insert(file_path, key); key } @@ -103,7 +139,7 @@ impl Library { let mut ancestors: HashMap> = HashMap::new(); let mut subsections: HashMap> = HashMap::new(); - for section in self.sections.values_mut() { + for (key, section) in self.sections.iter_mut() { // Make sure the pages of a section are empty since we can call that many times on `serve` section.pages = vec![]; section.ignored_pages = vec![]; @@ -112,7 +148,7 @@ impl Library { subsections // Using the original filename to work for multi-lingual sections .entry(grand_parent.join(§ion.file.filename)) - .or_insert_with(|| vec![]) + .or_insert_with(Vec::new) .push(section.file.path.clone()); } @@ -139,6 +175,16 @@ impl Library { } } ancestors.insert(section.file.path.clone(), parents); + + // populate translations if necessary + if self.is_multilingual { + self.translations + .entry(section.file.canonical.clone()) + .and_modify(|trans| { + trans.insert(key); + }) + .or_insert(set![key]); + }; } for (key, page) in &mut self.pages { @@ -157,7 +203,7 @@ impl Library { parent_is_transparent = section.meta.transparent; } page.ancestors = - ancestors.get(&parent_section_path).cloned().unwrap_or_else(|| vec![]); + ancestors.get(&parent_section_path).cloned().unwrap_or_else(Vec::new); // Don't forget to push the actual parent page.ancestors.push(*section_key); @@ -184,9 +230,18 @@ impl Library { None => break, } } + + // populate translations if necessary + if self.is_multilingual { + self.translations + .entry(page.file.canonical.clone()) + .and_modify(|trans| { + trans.insert(key); + }) + .or_insert(set![key]); + }; } - self.populate_translations(); self.sort_sections_pages(); let sections = self.paths_to_sections.clone(); @@ -201,8 +256,7 @@ impl Library { children.sort_by(|a, b| sections_weight[a].cmp(§ions_weight[b])); section.subsections = children; } - section.ancestors = - ancestors.get(§ion.file.path).cloned().unwrap_or_else(|| vec![]); + section.ancestors = ancestors.get(§ion.file.path).cloned().unwrap_or_else(Vec::new); } } @@ -276,51 +330,6 @@ impl Library { } } - /// Finds all the translations for each section/page and set the `translations` - /// field of each as needed - /// A no-op for sites without multiple languages - fn populate_translations(&mut self) { - if !self.is_multilingual { - return; - } - - // Sections first - let mut sections_translations = HashMap::new(); - for (key, section) in &self.sections { - sections_translations - .entry(section.file.canonical.clone()) // TODO: avoid this clone - .or_insert_with(Vec::new) - .push(key); - } - - for (key, section) in self.sections.iter_mut() { - let translations = §ions_translations[§ion.file.canonical]; - if translations.len() == 1 { - section.translations = vec![]; - continue; - } - section.translations = translations.iter().filter(|k| **k != key).cloned().collect(); - } - - // Same thing for pages - let mut pages_translations = HashMap::new(); - for (key, page) in &self.pages { - pages_translations - .entry(page.file.canonical.clone()) // TODO: avoid this clone - .or_insert_with(Vec::new) - .push(key); - } - - for (key, page) in self.pages.iter_mut() { - let translations = &pages_translations[&page.file.canonical]; - if translations.len() == 1 { - page.translations = vec![]; - continue; - } - page.translations = translations.iter().filter(|k| **k != key).cloned().collect(); - } - } - /// Find all the orphan pages: pages that are in a folder without an `_index.md` pub fn get_all_orphan_pages(&self) -> Vec<&Page> { let pages_in_sections = @@ -415,56 +424,17 @@ impl Library { /// This will check every section/page paths + the aliases and ensure none of them /// are colliding. /// Returns (path colliding, [list of files causing that collision]) - pub fn check_for_path_collisions(&self) -> Vec<(&str, Vec)> { - let mut paths: HashMap<&str, HashSet> = HashMap::new(); - - for (key, page) in &self.pages { - paths - .entry(&page.path) - .and_modify(|s| { - s.insert(key); - }) - .or_insert_with(|| set!(key)); - - for alias in &page.meta.aliases { - paths - .entry(&alias) - .and_modify(|s| { - s.insert(key); - }) - .or_insert_with(|| set!(key)); - } - } - - for (key, section) in &self.sections { - if !section.meta.render { - continue; - } - paths - .entry(§ion.path) - .and_modify(|s| { - s.insert(key); - }) - .or_insert_with(|| set!(key)); - } - - let mut collisions = vec![]; - for (p, keys) in paths { - if keys.len() > 1 { - let file_paths: Vec = keys - .iter() - .map(|k| { - self.pages.get(*k).map(|p| p.file.relative.clone()).unwrap_or_else(|| { - self.sections.get(*k).map(|s| s.file.relative.clone()).unwrap() - }) - }) - .collect(); - - collisions.push((p, file_paths)); - } - } - - collisions + pub fn check_for_path_collisions(&self) -> Vec<(String, Vec)> { + self.reverse_aliases + .iter() + .filter_map(|(alias, files)| { + if files.len() > 1 { + Some((alias.clone(), files.clone().into_iter().collect::>())) + } else { + None + } + }) + .collect() } } diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index c048bfef..f71d8d95 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -237,7 +237,7 @@ pub fn find_taxonomies(config: &Config, library: &Library) -> Result Clivo sub inprovisoque nostrum minus fama est, discordia patrem petebat precatur absumitur, poena per sit. Foramina *tamen cupidine* memor supplex tollentes dictum unam orbem, Anubis caecae. Viderat formosior tegebat satis, Aethiopasque -sit submisso coniuge tristis ubi! +sit submisso coniuge tristis ubi! :exclamation: ## Praeceps Corinthus totidem quem crus vultum cape @@ -68,7 +68,7 @@ And a shortcode: ### Another subsection Gotta make the toc do a little bit of work -# A big title +# A big title :fire: - hello - world @@ -96,7 +96,7 @@ fn bench_render_content_without_highlighting(b: &mut test::Bencher) { tera.add_raw_template("shortcodes/youtube.html", "{{id}}").unwrap(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = false; + config.markdown.highlight_code = false; let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); b.iter(|| render_content(CONTENT, &context).unwrap()); } @@ -106,7 +106,7 @@ fn bench_render_content_no_shortcode(b: &mut test::Bencher) { let tera = Tera::default(); let content2 = CONTENT.replace(r#"{{ youtube(id="my_youtube_id") }}"#, ""); let mut config = Config::default(); - config.highlight_code = false; + config.markdown.highlight_code = false; let permalinks_ctx = HashMap::new(); let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); @@ -123,3 +123,16 @@ fn bench_render_shortcodes_one_present(b: &mut test::Bencher) { b.iter(|| render_shortcodes(CONTENT, &context)); } + +#[bench] +fn bench_render_content_no_shortcode_with_emoji(b: &mut test::Bencher) { + let tera = Tera::default(); + let content2 = CONTENT.replace(r#"{{ youtube(id="my_youtube_id") }}"#, ""); + let mut config = Config::default(); + config.markdown.highlight_code = false; + config.markdown.render_emoji = true; + let permalinks_ctx = HashMap::new(); + let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + + b.iter(|| render_content(&content2, &context).unwrap()); +} diff --git a/components/rendering/src/context.rs b/components/rendering/src/context.rs index 8d877d1e..30249d36 100644 --- a/components/rendering/src/context.rs +++ b/components/rendering/src/context.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::collections::HashMap; use config::Config; @@ -7,11 +8,11 @@ use tera::{Context, Tera}; /// All the information from the zola site that is needed to render HTML from markdown #[derive(Debug)] pub struct RenderContext<'a> { - pub tera: &'a Tera, + pub tera: Cow<'a, Tera>, pub config: &'a Config, pub tera_context: Context, pub current_page_permalink: &'a str, - pub permalinks: &'a HashMap, + pub permalinks: Cow<'a, HashMap>, pub insert_anchor: InsertAnchor, } @@ -25,13 +26,25 @@ impl<'a> RenderContext<'a> { ) -> RenderContext<'a> { let mut tera_context = Context::new(); tera_context.insert("config", config); - RenderContext { - tera, + Self { + tera: Cow::Borrowed(tera), tera_context, current_page_permalink, - permalinks, + permalinks: Cow::Borrowed(permalinks), insert_anchor, config, } } + + // In use in the markdown filter + pub fn from_config(config: &'a Config) -> RenderContext<'a> { + Self { + tera: Cow::Owned(Tera::default()), + tera_context: Context::new(), + current_page_permalink: "", + permalinks: Cow::Owned(HashMap::new()), + insert_anchor: InsertAnchor::None, + config, + } + } } diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index ff419fbd..760e64be 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -13,7 +13,6 @@ use utils::slugs::slugify_anchors; use utils::vec::InsertMany; use self::cmark::{Event, LinkType, Options, Parser, Tag}; -use pulldown_cmark::CodeBlockKind; mod codeblock; mod fence; @@ -101,17 +100,12 @@ fn fix_link( return Ok(link.to_string()); } - // TODO: remove me in a few versions when people have upgraded - if link.starts_with("./") && link.contains(".md") { - println!("It looks like the link `{}` is using the previous syntax for internal links: start with @/ instead", link); - } - // A few situations here: // - it could be a relative link (starting with `@/`) // - it could be a link to a co-located asset // - it could be a normal link let result = if link.starts_with("@/") { - match resolve_internal_link(&link, context.permalinks) { + match resolve_internal_link(&link, &context.permalinks) { Ok(resolved) => { if resolved.anchor.is_some() { internal_links_with_anchors @@ -168,6 +162,10 @@ fn get_heading_refs(events: &[Event]) -> Vec { } pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result { + lazy_static! { + static ref EMOJI_REPLACER: gh_emoji::Replacer = gh_emoji::Replacer::new(); + } + // the rendered html let mut html = String::with_capacity(content.len()); // Set while parsing @@ -188,6 +186,10 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result Result { - if !context.config.highlight_code { + let language = match kind { + cmark::CodeBlockKind::Fenced(fence_info) => { + let fence_info = fence::FenceSettings::new(fence_info); + fence_info.language + } + _ => None, + }; + + if !context.config.highlight_code() { + if let Some(lang) = language { + let html = format!( + r#"
"#,
+                                    lang, lang
+                                );
+                                return Event::Html(html.into());
+                            }
                             return Event::Html("
".into());
                         }
 
-                        let theme = &THEME_SET.themes[&context.config.highlight_theme];
+                        let theme = &THEME_SET.themes[context.config.highlight_theme()];
                         match kind {
-                            CodeBlockKind::Indented => (),
-                            CodeBlockKind::Fenced(fence_info) => {
+                            cmark::CodeBlockKind::Indented => (),
+                            cmark::CodeBlockKind::Fenced(fence_info) => {
                                 // This selects the background color the same way that
                                 // start_coloured_html_snippet does
                                 let color = theme
@@ -227,11 +247,18 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result");
+                        if let Some(lang) = language {
+                            html.push_str(&format!(
+                                r#""#,
+                                lang, lang
+                            ));
+                        } else {
+                            html.push_str("");
+                        }
                         Event::Html(html.into())
                     }
                     Event::End(Tag::CodeBlock(_)) => {
-                        if !context.config.highlight_code {
+                        if !context.config.highlight_code() {
                             return Event::Html("
\n".into()); } // reset highlight and close the code block @@ -264,29 +291,42 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result { if markup.contains("") { has_summary = true; Event::Html(CONTINUE_READING.into()) - } else { - if in_html_block && markup.contains("
") { + } else if in_html_block && markup.contains("") { + in_html_block = false; + Event::Html(markup.replacen("", "", 1).into()) + } else if markup.contains("pre data-shortcode") { + in_html_block = true; + let m = markup.replacen("
", "", 1);
+                            if m.contains("
") { in_html_block = false; - Event::Html(markup.replacen("", "", 1).into()) - } else if markup.contains("pre data-shortcode") { - in_html_block = true; - let m = markup.replacen("
", "", 1);
-                                if m.contains("
") { - in_html_block = false; - Event::Html(m.replacen("", "", 1).into()) - } else { - Event::Html(m.into()) - } + Event::Html(m.replacen("", "", 1).into()) } else { - event + Event::Html(m.into()) } + } else { + event } } _ => event, @@ -348,7 +388,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result { impl<'config> CodeBlock<'config> { pub fn new(fence_info: &str, config: &'config Config, background: IncludeBackground) -> Self { let fence_info = FenceSettings::new(fence_info); - let theme = &THEME_SET.themes[&config.highlight_theme]; + let theme = &THEME_SET.themes[config.highlight_theme()]; let (highlighter, in_extra) = get_highlighter(fence_info.language, config); Self { highlighter, extra_syntax_set: match in_extra { - true => config.extra_syntax_set.as_ref(), + true => config.markdown.extra_syntax_set.as_ref(), false => None, }, background, diff --git a/components/rendering/src/shortcode.rs b/components/rendering/src/shortcode.rs index 497a28f4..aece80ee 100644 --- a/components/rendering/src/shortcode.rs +++ b/components/rendering/src/shortcode.rs @@ -3,6 +3,7 @@ use pest::iterators::Pair; use pest::Parser; use pest_derive::Parser; use regex::Regex; +use std::collections::HashMap; use tera::{to_value, Context, Map, Value}; use crate::context::RenderContext; @@ -102,6 +103,7 @@ fn render_shortcode( name: &str, args: &Map, context: &RenderContext, + invocation_count: u32, body: Option<&str>, ) -> Result { let mut tera_context = Context::new(); @@ -112,6 +114,7 @@ fn render_shortcode( // Trimming right to avoid most shortcodes with bodies ending up with a HTML new line tera_context.insert("body", b.trim_end()); } + tera_context.insert("nth", &invocation_count); tera_context.extend(context.tera_context.clone()); let mut template_name = format!("shortcodes/{}.md", name); @@ -139,6 +142,12 @@ fn render_shortcode( pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result { let mut res = String::with_capacity(content.len()); + let mut invocation_map: HashMap = HashMap::new(); + let mut get_invocation_count = |name: &str| { + let invocation_number = invocation_map.entry(String::from(name)).or_insert(0); + *invocation_number += 1; + *invocation_number + }; let mut pairs = match ContentParser::parse(Rule::page, content) { Ok(p) => p, @@ -184,7 +193,13 @@ pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result res.push_str(p.as_span().as_str()), Rule::inline_shortcode => { let (name, args) = parse_shortcode_call(p); - res.push_str(&render_shortcode(&name, &args, context, None)?); + res.push_str(&render_shortcode( + &name, + &args, + context, + get_invocation_count(&name), + None, + )?); } Rule::shortcode_with_body => { let mut inner = p.into_inner(); @@ -192,7 +207,13 @@ pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result { res.push_str( diff --git a/components/rendering/tests/codeblock_hl_lines.rs b/components/rendering/tests/codeblock_hl_lines.rs index bbbc3655..6f0eb7e4 100644 --- a/components/rendering/tests/codeblock_hl_lines.rs +++ b/components/rendering/tests/codeblock_hl_lines.rs @@ -37,7 +37,7 @@ fn hl_lines_simple() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -66,7 +66,7 @@ fn hl_lines_in_middle() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -95,7 +95,7 @@ fn hl_lines_all() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -122,7 +122,7 @@ fn hl_lines_start_from_one() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -150,7 +150,7 @@ fn hl_lines_start_from_zero() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -178,7 +178,7 @@ fn hl_lines_end() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -206,7 +206,7 @@ fn hl_lines_end_out_of_bounds() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -234,7 +234,7 @@ fn hl_lines_overlap() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -261,7 +261,7 @@ fn hl_lines_multiple() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -289,7 +289,7 @@ fn hl_lines_extra_spaces() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -317,7 +317,7 @@ fn hl_lines_int_and_range() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -346,7 +346,7 @@ fn hl_lines_single_line_range() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" @@ -375,7 +375,7 @@ fn hl_lines_reverse_range() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); let res = render_content( r#" diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index e37f9212..468ff8ac 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -23,7 +23,7 @@ fn doesnt_highlight_code_block_with_highlighting_off() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = false; + config.markdown.highlight_code = false; 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, "
$ gutenberg server\n
\n"); @@ -34,7 +34,7 @@ fn can_highlight_code_block_no_lang() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; 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!( @@ -48,12 +48,12 @@ fn can_highlight_code_block_with_lang() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; 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
" ); } @@ -62,13 +62,13 @@ fn can_higlight_code_block_with_unknown_lang() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let mut config = Config::default(); - config.highlight_code = true; + config.markdown.highlight_code = true; 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
" ); } @@ -87,7 +87,9 @@ Hello ) .unwrap(); assert!(res.body.contains("

Hello

\n
")); - assert!(res.body.contains(r#" +
diff --git a/components/templates/src/filters.rs b/components/templates/src/filters.rs index 5f4e521a..c9b6d6cd 100644 --- a/components/templates/src/filters.rs +++ b/components/templates/src/filters.rs @@ -2,38 +2,44 @@ use std::collections::HashMap; use std::hash::BuildHasher; use base64::{decode, encode}; -use pulldown_cmark as cmark; -use tera::{to_value, try_get_value, Result as TeraResult, Value}; +use config::Config; +use rendering::{render_content, RenderContext}; +use tera::{to_value, try_get_value, Filter as TeraFilter, Result as TeraResult, Value}; -pub fn markdown( - value: &Value, - args: &HashMap, -) -> TeraResult { - let s = try_get_value!("markdown", "value", String, value); - let inline = match args.get("inline") { - Some(val) => try_get_value!("markdown", "inline", bool, val), - None => false, - }; +#[derive(Debug)] +pub struct MarkdownFilter { + config: Config, +} - let mut opts = cmark::Options::empty(); - opts.insert(cmark::Options::ENABLE_TABLES); - opts.insert(cmark::Options::ENABLE_FOOTNOTES); - opts.insert(cmark::Options::ENABLE_STRIKETHROUGH); - opts.insert(cmark::Options::ENABLE_TASKLISTS); - - let mut html = String::new(); - let parser = cmark::Parser::new_ext(&s, opts); - cmark::html::push_html(&mut html, parser); - - if inline { - html = html - .trim_start_matches("

") - // pulldown_cmark finishes a paragraph with `

\n` - .trim_end_matches("

\n") - .to_string(); +impl MarkdownFilter { + pub fn new(config: Config) -> Self { + Self { config } } +} - Ok(to_value(&html).unwrap()) +impl TeraFilter for MarkdownFilter { + fn filter(&self, value: &Value, args: &HashMap) -> TeraResult { + let context = RenderContext::from_config(&self.config); + let s = try_get_value!("markdown", "value", String, value); + let inline = match args.get("inline") { + Some(val) => try_get_value!("markdown", "inline", bool, val), + None => false, + }; + let mut html = match render_content(&s, &context) { + Ok(res) => res.body, + Err(e) => return Err(format!("Failed to render markdown filter: {:?}", e).into()), + }; + + if inline { + html = html + .trim_start_matches("

") + // pulldown_cmark finishes a paragraph with `

\n` + .trim_end_matches("

\n") + .to_string(); + } + + Ok(to_value(&html).unwrap()) + } } pub fn base64_encode( @@ -56,22 +62,24 @@ pub fn base64_decode( mod tests { use std::collections::HashMap; - use tera::to_value; + use tera::{to_value, Filter}; - use super::{base64_decode, base64_encode, markdown}; + use super::{base64_decode, base64_encode, MarkdownFilter}; + use config::Config; #[test] fn markdown_filter() { - let result = markdown(&to_value(&"# Hey").unwrap(), &HashMap::new()); + let result = MarkdownFilter::new(Config::default()) + .filter(&to_value(&"# Hey").unwrap(), &HashMap::new()); assert!(result.is_ok()); - assert_eq!(result.unwrap(), to_value(&"

Hey

\n").unwrap()); + assert_eq!(result.unwrap(), to_value(&"

Hey

\n").unwrap()); } #[test] fn markdown_filter_inline() { let mut args = HashMap::new(); args.insert("inline".to_string(), to_value(true).unwrap()); - let result = markdown( + let result = MarkdownFilter::new(Config::default()).filter( &to_value(&"Using `map`, `filter`, and `fold` instead of `for`").unwrap(), &args, ); @@ -84,7 +92,7 @@ mod tests { fn markdown_filter_inline_tables() { let mut args = HashMap::new(); args.insert("inline".to_string(), to_value(true).unwrap()); - let result = markdown( + let result = MarkdownFilter::new(Config::default()).filter( &to_value( &r#" |id|author_id| timestamp_created|title |content | @@ -100,6 +108,26 @@ mod tests { assert!(result.unwrap().as_str().unwrap().contains("")); } + #[test] + fn markdown_filter_use_config_options() { + let mut config = Config::default(); + config.markdown.highlight_code = true; + config.markdown.smart_punctuation = true; + config.markdown.render_emoji = true; + config.markdown.external_links_target_blank = true; + + let md = "Hello :smile: ..."; + let result = + MarkdownFilter::new(config.clone()).filter(&to_value(&md).unwrap(), &HashMap::new()); + assert!(result.is_ok()); + assert_eq!(result.unwrap(), to_value(&"

Hello https://google.com 😄 …

\n").unwrap()); + + let md = "```py\ni=0\n```"; + let result = MarkdownFilter::new(config).filter(&to_value(&md).unwrap(), &HashMap::new()); + assert!(result.is_ok()); + assert!(result.unwrap().as_str().unwrap().contains("
 Ok(OutputFormat::Toml),
             "csv" => Ok(OutputFormat::Csv),
             "json" => Ok(OutputFormat::Json),
+            "bibtex" => Ok(OutputFormat::Bibtex),
             "plain" => Ok(OutputFormat::Plain),
             format => Err(format!("Unknown output format {}", format).into()),
         }
@@ -63,6 +65,7 @@ impl OutputFormat {
             OutputFormat::Json => "application/json",
             OutputFormat::Csv => "text/csv",
             OutputFormat::Toml => "application/toml",
+            OutputFormat::Bibtex => "application/x-bibtex",
             OutputFormat::Plain => "text/plain",
         })
     }
@@ -148,7 +151,7 @@ fn get_output_format_from_args(
     let format_arg = optional_arg!(
         String,
         args.get("format"),
-        "`load_data`: `format` needs to be an argument with a string value, being one of the supported `load_data` file types (csv, json, toml, plain)"
+        "`load_data`: `format` needs to be an argument with a string value, being one of the supported `load_data` file types (csv, json, toml, bibtex, plain)"
     );
 
     if let Some(format) = format_arg {
@@ -165,11 +168,11 @@ fn get_output_format_from_args(
     };
 
     // Always default to Plain if we don't know what it is
-    OutputFormat::from_str(from_extension).or_else(|_| Ok(OutputFormat::Plain))
+    OutputFormat::from_str(from_extension).or(Ok(OutputFormat::Plain))
 }
 
 /// A Tera function to load data from a file or from a URL
-/// Currently the supported formats are json, toml, csv and plain text
+/// Currently the supported formats are json, toml, csv, bibtex and plain text
 #[derive(Debug)]
 pub struct LoadData {
     base_path: PathBuf,
@@ -223,6 +226,7 @@ impl TeraFn for LoadData {
             OutputFormat::Toml => load_toml(data),
             OutputFormat::Csv => load_csv(data),
             OutputFormat::Json => load_json(data),
+            OutputFormat::Bibtex => load_bibtex(data),
             OutputFormat::Plain => to_value(data).map_err(|e| e.into()),
         };
 
@@ -252,6 +256,47 @@ fn load_toml(toml_data: String) -> Result {
     }
 }
 
+/// Parse a BIBTEX string and convert it to a Tera Value
+fn load_bibtex(bibtex_data: String) -> Result {
+    let bibtex_model = nom_bibtex::Bibtex::parse(&bibtex_data).map_err(|e| format!("{:?}", e))?;
+    let mut bibtex_map = Map::new();
+
+    let preambles_array =
+        bibtex_model.preambles().iter().map(|v| Value::String(v.to_string())).collect();
+    bibtex_map.insert(String::from("preambles"), Value::Array(preambles_array));
+
+    let comments_array =
+        bibtex_model.comments().iter().map(|v| Value::String(v.to_string())).collect();
+    bibtex_map.insert(String::from("comments"), Value::Array(comments_array));
+
+    let mut variables_map = Map::new();
+    for (key, val) in bibtex_model.variables() {
+        variables_map.insert(key.to_string(), Value::String(val.to_string()));
+    }
+    bibtex_map.insert(String::from("variables"), Value::Object(variables_map));
+
+    let bibliographies_array = bibtex_model
+        .bibliographies()
+        .iter()
+        .map(|b| {
+            let mut m = Map::new();
+            m.insert(String::from("entry_type"), Value::String(b.entry_type().to_string()));
+            m.insert(String::from("citation_key"), Value::String(b.citation_key().to_string()));
+
+            let mut tags = Map::new();
+            for (key, val) in b.tags() {
+                tags.insert(key.to_lowercase().to_string(), Value::String(val.to_string()));
+            }
+            m.insert(String::from("tags"), Value::Object(tags));
+            Value::Object(m)
+        })
+        .collect();
+    bibtex_map.insert(String::from("bibliographies"), Value::Array(bibliographies_array));
+
+    let bibtex_value: Value = Value::Object(bibtex_map);
+    to_value(bibtex_value).map_err(|err| err.into())
+}
+
 /// Parse a CSV string and convert it to a Tera Value
 ///
 /// An example csv file `example.csv` could be:
diff --git a/components/templates/src/global_fns/mod.rs b/components/templates/src/global_fns/mod.rs
index 2b3693d4..fa7bb283 100644
--- a/components/templates/src/global_fns/mod.rs
+++ b/components/templates/src/global_fns/mod.rs
@@ -39,7 +39,7 @@ impl TeraFn for Trans {
         let term = self
             .config
             .get_translation(lang, key)
-            .map_err(|e| Error::chain("Failed to retreive term translation", e))?;
+            .map_err(|e| Error::chain("Failed to retrieve term translation", e))?;
 
         Ok(to_value(term).unwrap())
     }
@@ -331,7 +331,7 @@ impl GetTaxonomyUrl {
             }
             taxonomies.insert(format!("{}-{}", taxo.kind.name, taxo.kind.lang), items);
         }
-        Self { taxonomies, default_lang: default_lang.to_string(), slugify: slugify }
+        Self { taxonomies, default_lang: default_lang.to_string(), slugify }
     }
 }
 impl TeraFn for GetTaxonomyUrl {
@@ -735,7 +735,7 @@ title = "A title"
 
         let config = Config::parse(TRANS_CONFIG).unwrap();
         let error = Trans::new(config).call(&args).unwrap_err();
-        assert_eq!("Failed to retreive term translation", format!("{}", error));
+        assert_eq!("Failed to retrieve term translation", format!("{}", error));
     }
 
     #[test]
@@ -746,7 +746,7 @@ title = "A title"
 
         let config = Config::parse(TRANS_CONFIG).unwrap();
         let error = Trans::new(config).call(&args).unwrap_err();
-        assert_eq!("Failed to retreive term translation", format!("{}", error));
+        assert_eq!("Failed to retrieve term translation", format!("{}", error));
     }
 
     #[test]
diff --git a/components/templates/src/lib.rs b/components/templates/src/lib.rs
index a0ca5947..eef42267 100644
--- a/components/templates/src/lib.rs
+++ b/components/templates/src/lib.rs
@@ -36,7 +36,6 @@ lazy_static! {
             ("internal/alias.html", include_str!("builtins/internal/alias.html")),
         ])
         .unwrap();
-        tera.register_filter("markdown", filters::markdown);
         tera.register_filter("base64_encode", filters::base64_encode);
         tera.register_filter("base64_decode", filters::base64_decode);
         tera
diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml
index 9923f80f..2c2f664e 100644
--- a/components/utils/Cargo.toml
+++ b/components/utils/Cargo.toml
@@ -15,6 +15,7 @@ serde_derive = "1"
 slug = "0.1"
 percent-encoding = "2"
 filetime = "0.2.12"
+minify-html = "0.4"
 
 errors = { path = "../errors" }
 
diff --git a/components/utils/src/de.rs b/components/utils/src/de.rs
index 654eaee1..e294e92a 100644
--- a/components/utils/src/de.rs
+++ b/components/utils/src/de.rs
@@ -1,12 +1,32 @@
 use serde::{Deserialize, Deserializer};
+use serde_derive::Deserialize;
 use tera::{Map, Value};
 
 /// Used as an attribute when we want to convert from TOML to a string date
+/// If a TOML datetime isn't present, it will accept a string and push it through
+/// TOML's date time parser to ensure only valid dates are accepted.
+/// Inspired by this proposal: https://github.com/alexcrichton/toml-rs/issues/269
 pub fn from_toml_datetime<'de, D>(deserializer: D) -> Result, D::Error>
 where
     D: Deserializer<'de>,
 {
-    toml::value::Datetime::deserialize(deserializer).map(|s| Some(s.to_string()))
+    use serde::de::Error;
+    use std::str::FromStr;
+
+    #[derive(Deserialize)]
+    #[serde(untagged)]
+    enum MaybeDatetime {
+        Datetime(toml::value::Datetime),
+        String(String),
+    }
+
+    match MaybeDatetime::deserialize(deserializer)? {
+        MaybeDatetime::Datetime(d) => Ok(Some(d.to_string())),
+        MaybeDatetime::String(s) => match toml::value::Datetime::from_str(&s) {
+            Ok(d) => Ok(Some(d.to_string())),
+            Err(e) => Err(D::Error::custom(e)),
+        },
+    }
 }
 
 /// Returns key/value for a converted date from TOML.
diff --git a/components/utils/src/fs.rs b/components/utils/src/fs.rs
index 2b8e1c5f..a46f6d94 100644
--- a/components/utils/src/fs.rs
+++ b/components/utils/src/fs.rs
@@ -20,8 +20,8 @@ pub fn is_path_in_directory(parent: &Path, path: &Path) -> Result {
 
 /// Create a file with the content given
 pub fn create_file(path: &Path, content: &str) -> Result<()> {
-    let mut file =
-        File::create(&path).map_err(|e| Error::chain(format!("Failed to create {:?}", path), e))?;
+    let mut file = File::create(&path)
+        .map_err(|e| Error::chain(format!("Failed to create file {}", path.display()), e))?;
     file.write_all(content.as_bytes())?;
     Ok(())
 }
@@ -62,7 +62,7 @@ pub fn read_file(path: &Path) -> Result {
 
 /// Return the content of a file, with error handling added.
 /// The default error message is overwritten by the message given.
-/// That means it is allocation 2 strings, oh well
+/// That means it is allocating 2 strings, oh well
 pub fn read_file_with_error(path: &Path, message: &str) -> Result {
     let res = read_file(&path);
     if res.is_ok() {
@@ -101,7 +101,9 @@ pub fn copy_file(src: &Path, dest: &PathBuf, base_path: &PathBuf, hard_link: boo
     let target_path = dest.join(relative_path);
 
     if let Some(parent_directory) = target_path.parent() {
-        create_dir_all(parent_directory)?;
+        create_dir_all(parent_directory).map_err(|e| {
+            Error::chain(format!("Was not able to create folder {}", parent_directory.display()), e)
+        })?;
     }
 
     copy_file_if_needed(src, &target_path, hard_link)
@@ -113,7 +115,9 @@ pub fn copy_file(src: &Path, dest: &PathBuf, base_path: &PathBuf, hard_link: boo
 /// 3. Its filesize is identical to that of the src file.
 pub fn copy_file_if_needed(src: &Path, dest: &PathBuf, hard_link: bool) -> Result<()> {
     if let Some(parent_directory) = dest.parent() {
-        create_dir_all(parent_directory)?;
+        create_dir_all(parent_directory).map_err(|e| {
+            Error::chain(format!("Was not able to create folder {}", parent_directory.display()), e)
+        })?;
     }
 
     if hard_link {
@@ -125,11 +129,25 @@ pub fn copy_file_if_needed(src: &Path, dest: &PathBuf, hard_link: bool) -> Resul
             let target_metadata = metadata(&dest)?;
             let target_mtime = FileTime::from_last_modification_time(&target_metadata);
             if !(src_mtime == target_mtime && src_metadata.len() == target_metadata.len()) {
-                copy(src, &dest)?;
+                copy(src, &dest).map_err(|e| {
+                    Error::chain(
+                        format!(
+                            "Was not able to copy file {} to {}",
+                            src.display(),
+                            dest.display()
+                        ),
+                        e,
+                    )
+                })?;
                 set_file_mtime(&dest, src_mtime)?;
             }
         } else {
-            copy(src, &dest)?;
+            copy(src, &dest).map_err(|e| {
+                Error::chain(
+                    format!("Was not able to copy file {} to {}", src.display(), dest.display()),
+                    e,
+                )
+            })?;
             set_file_mtime(&dest, src_mtime)?;
         }
     }
@@ -146,7 +164,16 @@ pub fn copy_directory(src: &PathBuf, dest: &PathBuf, hard_link: bool) -> Result<
                 create_directory(&target_path)?;
             }
         } else {
-            copy_file(entry.path(), dest, src, hard_link)?;
+            copy_file(entry.path(), dest, src, hard_link).map_err(|e| {
+                Error::chain(
+                    format!(
+                        "Was not able to copy file {} to {}",
+                        entry.path().display(),
+                        dest.display()
+                    ),
+                    e,
+                )
+            })?;
         }
     }
     Ok(())
diff --git a/components/utils/src/lib.rs b/components/utils/src/lib.rs
index 44ebf4ed..eac2325d 100644
--- a/components/utils/src/lib.rs
+++ b/components/utils/src/lib.rs
@@ -1,5 +1,6 @@
 pub mod de;
 pub mod fs;
+pub mod minify;
 pub mod net;
 pub mod site;
 pub mod slugs;
diff --git a/components/utils/src/minify.rs b/components/utils/src/minify.rs
new file mode 100644
index 00000000..0073585f
--- /dev/null
+++ b/components/utils/src/minify.rs
@@ -0,0 +1,50 @@
+use errors::{bail, Result};
+use minify_html::{with_friendly_error, Cfg};
+
+pub fn html(html: String) -> Result {
+    let cfg = &Cfg { minify_js: false, minify_css: false };
+    let mut input_bytes = html.as_bytes().to_vec();
+
+    match with_friendly_error(&mut input_bytes, cfg) {
+        Ok(len) => match std::str::from_utf8(&input_bytes) {
+            Ok(result) => Ok(result[..len].to_string()),
+            Err(err) => bail!("Failed to convert bytes to string : {}", err),
+        },
+        Err(minify_error) => {
+            bail!(
+                "Failed to truncate html at character {}: {} \n {}",
+                minify_error.position,
+                minify_error.message,
+                minify_error.code_context
+            );
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    // https://github.com/getzola/zola/issues/1292
+    #[test]
+    fn can_minify_html() {
+        let input = r#"
+
+
+
+  
+
+
+
+
+    

Example blog post

+ + FOO BAR + + +"#; + let expected = r#"

Example blog post

FOO BAR"#; + let res = html(input.to_owned()).unwrap(); + assert_eq!(res, expected); + } +} diff --git a/docs/content/documentation/content/multilingual.md b/docs/content/documentation/content/multilingual.md index 443e7e49..cd697ff5 100644 --- a/docs/content/documentation/content/multilingual.md +++ b/docs/content/documentation/content/multilingual.md @@ -33,8 +33,8 @@ uses the filename to detect the language: - `content/an-article.md`: this will be the default language - `content/an-article.fr.md`: this will be in French -If the language code in the filename does not correspond to one of the languages configured, -an error will be shown. +If the language code in the filename does not correspond to one of the languages or +the default language configured, an error will be shown. If your default language has an `_index.md` in a directory, you will need to add an `_index.{code}.md` file with the desired front-matter options as there is no language fallback. diff --git a/docs/content/documentation/content/page.md b/docs/content/documentation/content/page.md index d04da579..ac6ac242 100644 --- a/docs/content/documentation/content/page.md +++ b/docs/content/documentation/content/page.md @@ -79,6 +79,9 @@ by triple pluses (`+++`). Although none of the front matter variables are mandatory, the opening and closing `+++` are required. +Note that even though the use of TOML is encouraged, YAML front matter is also supported to ease porting +legacy content. In this case the embedded metadata must be enclosed by triple minuses (`---`). + Here is an example page with all the available variables. The values provided below are the default values. diff --git a/docs/content/documentation/content/section.md b/docs/content/documentation/content/section.md index 80003aea..fd9f9916 100644 --- a/docs/content/documentation/content/section.md +++ b/docs/content/documentation/content/section.md @@ -18,6 +18,9 @@ Any non-Markdown file in a section directory is added to the `assets` collection [content overview](@/documentation/content/overview.md#asset-colocation). These files are then available in the Markdown file using relative links. +## Drafting +Just like pages sections can be drafted by setting the `draft` option in the front matter. By default this is not done. When a section is drafted it's descendants like pages, subsections and assets will not be processed unless the `--drafts` flag is passed. Note that even pages that don't have a `draft` status will not be processed if one of their parent sections is drafted. + ## Front matter The `_index.md` file within a directory defines the content and metadata for that section. To set @@ -30,6 +33,9 @@ to your templates through the `section.content` variable. Although none of the front matter variables are mandatory, the opening and closing `+++` are required. +Note that even though the use of TOML is encouraged, YAML front matter is also supported to ease porting +legacy content. In this case the embedded metadata must be enclosed by triple minuses (`---`). + Here is an example `_index.md` with all the available variables. The values provided below are the default values. @@ -39,6 +45,9 @@ title = "" description = "" +# A draft section is only loaded if the `--drafts` flag is passed to `zola build`, `zola serve` or `zola check`. +draft = false + # Used to sort pages by "date", "weight" or "none". See below for more information. sort_by = "none" diff --git a/docs/content/documentation/content/shortcodes.md b/docs/content/documentation/content/shortcodes.md index b0fba7f9..8deb23c3 100644 --- a/docs/content/documentation/content/shortcodes.md +++ b/docs/content/documentation/content/shortcodes.md @@ -134,6 +134,24 @@ If you want to have some content that looks like a shortcode but not have Zola t you will need to escape it by using `{%/*` and `*/%}` instead of `{%` and `%}`. You won't need to escape anything else until the closing tag. +### Invocation Count + +Every shortcode context is passed in a variable named `nth` that tracks how many times a particular shortcode has +been invoked in a Markdown file. Given a shortcode `true_statement.html` template: + +```jinja2 +

{{ value }} is equal to {{ nth }}.

+``` + +It could be used in our Markdown as follows: + +```md +{{/* true_statement(value=1) */}} +{{/* true_statement(value=2) */}} +``` + +This is useful when implementing custom markup for features such as sidenotes or end notes. + ## Built-in shortcodes Zola comes with a few built-in shortcodes. If you want to override a default shortcode template, diff --git a/docs/content/documentation/content/syntax-highlighting.md b/docs/content/documentation/content/syntax-highlighting.md index 4143567e..1dde1c32 100644 --- a/docs/content/documentation/content/syntax-highlighting.md +++ b/docs/content/documentation/content/syntax-highlighting.md @@ -35,7 +35,7 @@ Here is a full list of supported languages and their short names: - C -> ["c", "h"] - C# -> ["cs", "csx"] - C++ -> ["C", "c++", "cc", "cp", "cpp", "cxx", "h", "h++", "hh", "hpp", "hxx", "inl", "ipp"] -- Clojure -> ["clj", "cljc", "cljs", "edn"] +- ClojureC -> ["boot", "clj", "cljc", "cljs", "cljx"] - CMake -> ["CMakeLists.txt", "cmake"] - CMake C Header -> ["h.in"] - CMake C++ Header -> ["h++.in", "hh.in", "hpp.in", "hxx.in"] @@ -46,6 +46,7 @@ Here is a full list of supported languages and their short names: - Dart -> ["dart"] - Diff -> ["diff", "patch"] - Dockerfile -> ["Dockerfile", "dockerfile"] +- EDN -> ["edn"] - Elixir -> ["ex", "exs"] - Elm -> ["elm"] - Erlang -> ["Emakefile", "emakefile", "erl", "escript", "hrl"] @@ -66,7 +67,7 @@ Here is a full list of supported languages and their short names: - Git Rebase Todo -> ["git-rebase-todo"] - GLSL -> ["comp", "frag", "fs", "fsh", "fshader", "geom", "glsl", "gs", "gsh", "gshader", "tesc", "tese", "vert", "vs", "vsh", "vshader"] - Go -> ["go"] -- GraphQL -> ["gql", "graphql"] +- GraphQL -> ["gql", "graphql", "graphqls"] - Graphviz (DOT) -> ["DOT", "dot", "gv"] - Groovy -> ["Jenkinsfile", "gradle", "groovy", "gvy"] - Handlebars -> ["handlebars", "handlebars.html", "hbr", "hbrs", "hbs", "hdbs", "hjs", "mu", "mustache", "rac", "stache", "template", "tmpl"] @@ -144,6 +145,9 @@ Here is a full list of supported languages and their short names: - YAML -> ["sublime-syntax", "yaml", "yml"] ``` +Note: due to some issues with the JavaScript syntax, the TypeScript syntax will be used instead. +If + If you want to highlight a language not on this list, please open an issue or a pull request on the [Zola repo](https://github.com/getzola/zola). Alternatively, the `extra_syntaxes` configuration option can be used to add additional syntax files. diff --git a/docs/content/documentation/content/taxonomies.md b/docs/content/documentation/content/taxonomies.md index 8cc2a84e..39e78a04 100644 --- a/docs/content/documentation/content/taxonomies.md +++ b/docs/content/documentation/content/taxonomies.md @@ -3,7 +3,62 @@ title = "Taxonomies" weight = 90 +++ -Zola has built-in support for taxonomies. +Zola has built-in support for taxonomies. Taxonomies are a way for users to group content according to user-defined categories. + +## Definitions + +- Taxonomy: A category that can be used to group content +- Term: A specific group within a taxonomy +- Value: A piece of content that can be associated with a term + +## Example: a movie website + +Imagine that you want to make a website to display information about various movies. In that case you could use the following taxonomies: + +- Director +- Genres +- Awards +- Release year + +Then at build time Zola can create pages for each taxonomy listing all of the known terms as well as pages for each term in a taxonomy, listing all of the pieces of content associated with that term. + +Imagine again we have the following movies: +``` +- Shape of water <--- Value + - Director <--- Taxonomy + - Guillermo Del Toro <--- Term + - Genres <--- Taxonomy + - Thriller <--- Term + - Drama <--- Term + - Awards <--- Taxonomy + - Golden globe <--- Term + - Academy award <--- Term + - BAFTA <--- Term + - Release year <--- Taxonomy + - 2017 <--- Term + +- The Room: <--- Value + - Director <--- Taxonomy + - Tommy Wiseau <--- Term + - Genres <--- Taxonomy + - Romance <--- Term + - Drama <--- Term + - Release Year <--- Taxonomy + - 2003 <--- Term + +- Bright <--- Value + - Director <--- Taxonomy + - David Ayer <--- Term + - Genres <--- Taxonomy + - Fantasy <--- Term + - Action <--- Term + - Awards <--- Taxonomy + - California on Location Awards <--- Term + - Release Year <--- Taxonomy + - 2017 <--- Term +``` + +In this example the page for `Release year` would include links to pages for both 2003 and 2017, where the page for 2017 would list both Shape of Water and Bright. ## Configuration @@ -23,16 +78,30 @@ Insert into the configuration file (config.toml): **Example 1:** (one language) ```toml -taxonomies = [ name = "categories", rss = true ] +taxonomies = [ + { name = "director", feed = true}, + { name = "genres", feed = true}, + { name = "awards", feed = true}, + { name = "release-year", feed = true}, +] ``` **Example 2:** (multilingual site) ```toml taxonomies = [ - {name = "tags", lang = "fr"}, - {name = "tags", lang = "eo"}, - {name = "tags", lang = "en"}, + {name = "director", feed = true, lang = "fr"}, + {name = "director", feed = true, lang = "eo"}, + {name = "director", feed = true, lang = "en"}, + {name = "genres", feed = true, lang = "fr"}, + {name = "genres", feed = true, lang = "eo"}, + {name = "genres", feed = true, lang = "en"}, + {name = "awards", feed = true, lang = "fr"}, + {name = "awards", feed = true, lang = "eo"}, + {name = "awards", feed = true, lang = "en"}, + {name = "release-year", feed = true, lang = "fr"}, + {name = "release-year", feed = true, lang = "eo"}, + {name = "release-year", feed = true, lang = "en"}, ] ``` @@ -44,11 +113,13 @@ Once the configuration is done, you can then set taxonomies in your content and ```toml +++ -title = "Writing a static-site generator in Rust" -date = 2019-08-15 +title = "Shape of water" +date = 2019-08-15 # date of the post, not the movie [taxonomies] -tags = ["rust", "web"] -categories = ["programming"] +director=["Guillermo Del Toro"] +genres=["Thriller","Drama"] +awards=["Golden Globe", "Academy award", "BAFTA"] +release-year = ["2017"] +++ ``` diff --git a/docs/content/documentation/getting-started/configuration.md b/docs/content/documentation/getting-started/configuration.md index 96ad924f..71c1de2a 100644 --- a/docs/content/documentation/getting-started/configuration.md +++ b/docs/content/documentation/getting-started/configuration.md @@ -13,11 +13,12 @@ If you are not familiar with TOML, have a look at [the TOML spec](https://github Here are the current `config.toml` sections: 1. main (unnamed) -2. link_checker -3. slugify -4. search -5. translations -6. extra +2. markdown +3. link_checker +4. slugify +5. search +6. translations +7. extra **Only the `base_url` variable is mandatory**. Everything else is optional. All configuration variables used by Zola as well as their default values are listed below: @@ -36,13 +37,6 @@ default_language = "en" # The site theme to use. theme = "" -# When set to "true", all code blocks are highlighted. -highlight_code = false - -# The theme to use for code highlighting. -# See below for list of allowed values. -highlight_theme = "base16-ocean-dark" - # When set to "true", a feed is automatically generated. generate_feed = false @@ -86,6 +80,9 @@ languages = [] # Sass files in theme directories are always compiled. compile_sass = false +# When set to "true", the generated HTML files are minified. +minify_html = false + # A list of glob patterns specifying asset files to ignore when the content # directory is processed. Defaults to none, which means that all asset files are # copied over to the `public` directory. @@ -96,6 +93,36 @@ ignored_content = [] # A list of directories used to search for additional `.sublime-syntax` files. extra_syntaxes = [] +# You can override the default output directory `public` by setting an another value. +# output_dir = "docs" + +# Configuration of the Markdown rendering +[markdown] +# When set to "true", all code blocks are highlighted. +highlight_code = false + +# The theme to use for code highlighting. +# See below for list of allowed values. +highlight_theme = "base16-ocean-dark" + +# When set to "true", emoji aliases translated to their corresponding +# Unicode emoji equivalent in the rendered Markdown files. (e.g.: :smile: => 😄) +render_emoji = false + +# Whether external links are to be opened in a new tab +# If this is true, a `rel="noopener"` will always automatically be added for security reasons +external_links_target_blank = false + +# Whether to set rel="nofollow" for all external links +external_links_no_follow = false + +# Whether to set rel="noreferrer" for all external links +external_links_no_referrer = false + +# Whether smart punctuation is enabled (changing quotes, dashes, dots in their typographic form) +# For example, `...` into `…`, `"quote"` into `“curly”` etc +smart_punctuation = false + # Configuration of the link checker. [link_checker] # Skip link checking for external URLs that start with these prefixes diff --git a/docs/content/documentation/getting-started/installation.md b/docs/content/documentation/getting-started/installation.md index 3fd9aaca..0f09748b 100644 --- a/docs/content/documentation/getting-started/installation.md +++ b/docs/content/documentation/getting-started/installation.md @@ -77,7 +77,7 @@ $ choco install zola Zola does not work in PowerShell ISE. ## From source -To build Zola from source, you will need to have Git, [Rust (at least 1.43) and Cargo](https://www.rust-lang.org/) +To build Zola from source, you will need to have Git, [Rust (at least 1.45) and Cargo](https://www.rust-lang.org/) installed. You will also need to meet additional dependencies to compile [libsass](https://github.com/sass/libsass): - OSX, Linux and other Unix-like operating systems: `make` (`gmake` on BSDs), `g++`, `libssl-dev` diff --git a/docs/content/documentation/getting-started/overview.md b/docs/content/documentation/getting-started/overview.md index 06e590dd..10604816 100644 --- a/docs/content/documentation/getting-started/overview.md +++ b/docs/content/documentation/getting-started/overview.md @@ -173,7 +173,7 @@ We now need to make the `blog-page.html` template. In the `templates` directory, {{ page.title }}

{{ page.date }}

-

{{ page.content | safe }}

+{{ page.content | safe }} {% endblock content %} ``` diff --git a/docs/content/documentation/templates/overview.md b/docs/content/documentation/templates/overview.md index 2150225e..24fc0b5f 100644 --- a/docs/content/documentation/templates/overview.md +++ b/docs/content/documentation/templates/overview.md @@ -109,7 +109,7 @@ If you only need the metadata of the section, you can pass `metadata_only=true` {% set section = get_section(path="blog/_index.md", metadata_only=true) %} ``` -### ` get_url` +### `get_url` Gets the permalink for the given path. If the path starts with `@/`, it will be treated as an internal link like the ones used in Markdown, starting from the root `content` directory. @@ -146,7 +146,7 @@ In the case of non-internal links, you can also add a cachebust of the format `? by passing `cachebust=true` to the `get_url` function. -### 'get_file_hash` +### `get_file_hash` Gets the hash digest for a static file. Supported hashes are SHA-256, SHA-384 (default) and SHA-512. Requires `path`. The `sha_type` key is optional and must be one of 256, 384 or 512. @@ -202,7 +202,7 @@ items: Array; See the [Taxonomies documentation](@/documentation/templates/taxonomies.md) for a full documentation of those types. ### `load_data` -Loads data from a file or URL. Supported file types include *toml*, *json* and *csv*. +Loads data from a file or URL. Supported file types include *toml*, *json*, *csv* and *bibtex*. Any other file type will be loaded as plain text. The `path` argument specifies the path to the data file relative to your base directory, where your `config.toml` is. @@ -213,7 +213,7 @@ As a security precaution, if this file is outside the main site directory, your ``` The optional `format` argument allows you to specify and override which data type is contained -within the file specified in the `path` argument. Valid entries are `toml`, `json`, `csv` +within the file specified in the `path` argument. Valid entries are `toml`, `json`, `csv`, `bibtex` or `plain`. If the `format` argument isn't specified, then the path extension is used. ```jinja2 @@ -251,6 +251,58 @@ template: } ``` +The `bibtex` format loads data into a structure matching the format used by the +[nom-bibtex crate](https://crates.io/crates/nom-bibtex). The following is an example of data +in bibtex format: + +``` +@preamble{"A bibtex preamble" # " this is."} + +@Comment{ + Here is a comment. +} + +Another comment! + +@string(name = "Vincent Prouillet") +@string(github = "https://github.com/getzola/zola") + +@misc {my_citation_key, + author= name, + title = "Zola", + note = "github: " # github +} } +``` + +The following is the json-equivalent format of the produced bibtex data structure: +```json +{ + "preambles": ["A bibtex preamble this is."], + "comments": ["Here is a comment.", "Another comment!"], + "variables": { + "name": "Vincent Prouillet", + "github": "https://github.com/getzola/zola" + }, + "bibliographies": [ + { + "entry_type": "misc", + "citation_key": "my_citation_key", + "tags": { + "author": "Vincent Prouillet", + "title": "Zola", + "note": "github: https://github.com/getzola/zola" + } + } + ] +} +``` + +Finally, the bibtex data can be accessed from the template as follows: +```jinja2 +{% set tags = data.bibliographies[0].tags %} +This was generated using {{ tags.title }}, authored by {{ tags.author }}. +``` + #### Remote content Instead of using a file, you can load data from a remote URL. This can be done by specifying a `url` parameter diff --git a/docs/content/documentation/templates/pagination.md b/docs/content/documentation/templates/pagination.md index 3308b452..ff00a71c 100644 --- a/docs/content/documentation/templates/pagination.md +++ b/docs/content/documentation/templates/pagination.md @@ -49,3 +49,31 @@ A paginated taxonomy gets two variables aside from the `paginator` variable: - a `term` variable of type `TaxonomyTerm`. See the [taxonomies page](@/documentation/templates/taxonomies.md) for a detailed version of the types. + +## Example + +Here is an example from a theme on how to use pagination on a page (`index.html` in this case): + +```jinja2 +
+ {% for page in paginator.pages %} +
+ {{ post_macros::title(page=page) }} +
+ {{ page.summary | safe }} +
+ +
+ {% endfor %} +
+ +``` \ No newline at end of file diff --git a/docs/content/documentation/templates/robots.md b/docs/content/documentation/templates/robots.md index a6041f9c..40a10895 100644 --- a/docs/content/documentation/templates/robots.md +++ b/docs/content/documentation/templates/robots.md @@ -11,4 +11,6 @@ and the default is what most sites want: ```jinja2 User-agent: * +Allow: / +Sitemap: {{/* get_url(path="sitemap.xml") */}} ``` diff --git a/docs/content/themes/DeepThought/index.md b/docs/content/themes/DeepThought/index.md index b7ac8c0c..d9c27f4e 100644 --- a/docs/content/themes/DeepThought/index.md +++ b/docs/content/themes/DeepThought/index.md @@ -3,11 +3,11 @@ title = "DeepThought" description = "A simple blog theme focused on writing powered by Bulma and Zola." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/RatanShreshtha/DeepThought.git" homepage = "https://github.com/RatanShreshtha/DeepThought" minimum_version = "0.9.0" diff --git a/docs/content/themes/DeepThought/screenshot.png b/docs/content/themes/DeepThought/screenshot.png deleted file mode 100644 index 43ee5877..00000000 Binary files a/docs/content/themes/DeepThought/screenshot.png and /dev/null differ diff --git a/docs/content/themes/Ergo/index.md b/docs/content/themes/Ergo/index.md index d179db02..bcdad86e 100644 --- a/docs/content/themes/Ergo/index.md +++ b/docs/content/themes/Ergo/index.md @@ -3,11 +3,11 @@ title = "Ergo" description = "A simple blog Theme focused on writing, inspired by svbtle" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/InsidiousMind/Ergo.git" homepage = "https://github.com/insipx/Ergo" minimum_version = "0.4.1" @@ -42,8 +42,10 @@ Here's a timelapse: Get [Zola](https://www.getzola.org/) and/or follow their guide on [installing a theme](https://www.getzola.org/documentation/themes/installing-and-using-themes/). Make sure to add `theme = "ergo"` to your `config.toml` -#### Check zola version (only 0.4.1+) -Just to double-check to make sure you have the right version. It is not supported to use this theme with a version under 0.4.1. +Ergo relies on having `paginate_by` variable set in `content/_index.md`. + +#### Check zola version (only 0.11.0+) +Just to double-check to make sure you have the right version. It is not supported to use this theme with a version under 0.11.0. ### how to serve go into your sites directory, and type `zola serve`. You should see your new site at `localhost:1111`. @@ -64,6 +66,9 @@ profile = 'profile.svg' # Description. This is needed for SEO/site metadata purposes description = "Simple blog theme focused on writing, inspired by svbtle" +# Color themes used by the theme (theme will use ${color_theme}.css file, generated by SASS or SCSS file with the same name). Defaults to ["default"]. User can choose either of them, default theme is the first in list. +color_themes = ["my-awesome-theme", "default"] + # website, should not be preceded with `http://` website = "code.liquidthink.net" @@ -84,6 +89,8 @@ reddit = "${your_reddit}" # youtube youtube = "${your_youtube_channel_id}" # if any social networks are missing from this list that you want added, open an issue. I will add it for you ASAP +# Whether to use country flags or language code +country_flags = true ``` ## Features @@ -92,7 +99,7 @@ youtube = "${your_youtube_channel_id}" - [ ] Edit Colors in `config.toml` - [x] NoJS - [ ] Analytics - - [ ] Comments? + - [x] Comments? - [ ] Like button http://kudosplease.com/ - [ ] categories? - [ ] related posts? (would meaningful related posts, or unmeaningful ones, be worth it w/o database?) diff --git a/docs/content/themes/Ergo/screenshot.png b/docs/content/themes/Ergo/screenshot.png deleted file mode 100644 index 6b1d959f..00000000 Binary files a/docs/content/themes/Ergo/screenshot.png and /dev/null differ diff --git a/docs/content/themes/Zulma/index.md b/docs/content/themes/Zulma/index.md index f1c2216d..cda1017a 100644 --- a/docs/content/themes/Zulma/index.md +++ b/docs/content/themes/Zulma/index.md @@ -3,11 +3,11 @@ title = "Zulma" description = "A zola theme based off bulma.css" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/Worble/Zulma" homepage = "https://github.com/Worble/Zulma" minimum_version = "0.6.0" diff --git a/docs/content/themes/Zulma/screenshot.png b/docs/content/themes/Zulma/screenshot.png deleted file mode 100644 index 5373667a..00000000 Binary files a/docs/content/themes/Zulma/screenshot.png and /dev/null differ diff --git a/docs/content/themes/_index.md b/docs/content/themes/_index.md index 5aa2e7b5..752185dc 100644 --- a/docs/content/themes/_index.md +++ b/docs/content/themes/_index.md @@ -1,6 +1,4 @@ - +++ template = "themes.html" sort_by = "date" -+++ - \ No newline at end of file ++++ diff --git a/docs/content/themes/after-dark/index.md b/docs/content/themes/after-dark/index.md index 970b6b25..f7be857a 100644 --- a/docs/content/themes/after-dark/index.md +++ b/docs/content/themes/after-dark/index.md @@ -3,11 +3,11 @@ title = "after-dark" description = "A robust, elegant dark theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/getzola/after-dark.git" homepage = "https://github.com/getzola/after-dark" minimum_version = "0.11.0" diff --git a/docs/content/themes/after-dark/screenshot.png b/docs/content/themes/after-dark/screenshot.png deleted file mode 100644 index e34718d6..00000000 Binary files a/docs/content/themes/after-dark/screenshot.png and /dev/null differ diff --git a/docs/content/themes/anpu/index.md b/docs/content/themes/anpu/index.md index 4ba5836e..fa4037f8 100644 --- a/docs/content/themes/anpu/index.md +++ b/docs/content/themes/anpu/index.md @@ -3,11 +3,11 @@ title = "Anpu" description = "A port of the Hugo Anubis theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/zbrox/anpu-zola-theme.git" homepage = "https://github.com/zbrox/anpu-zola-theme" minimum_version = "0.11.0" diff --git a/docs/content/themes/anpu/screenshot.png b/docs/content/themes/anpu/screenshot.png deleted file mode 100644 index 9d472012..00000000 Binary files a/docs/content/themes/anpu/screenshot.png and /dev/null differ diff --git a/docs/content/themes/book/index.md b/docs/content/themes/book/index.md index fd304cb5..8f640d15 100644 --- a/docs/content/themes/book/index.md +++ b/docs/content/themes/book/index.md @@ -3,11 +3,11 @@ title = "book" description = "A book theme inspired from GitBook/mdBook" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/getzola/book.git" homepage = "https://github.com/getzola/book" minimum_version = "0.5.0" @@ -68,10 +68,10 @@ slug `introduction`, then you would set `redirect_to = "introduction"`. ### Numbered chapters By default, the `book` theme will number the chapters and pages in the left menu. -You can disable that by setting the `book_numbered_chapters` in `extra`: +You can disable that by setting the `book_number_chapters` in `extra`: ```toml -book_numbered_chapters = false +book_number_chapters = false ``` \ No newline at end of file diff --git a/docs/content/themes/book/screenshot.png b/docs/content/themes/book/screenshot.png deleted file mode 100644 index d4dfd078..00000000 Binary files a/docs/content/themes/book/screenshot.png and /dev/null differ diff --git a/docs/content/themes/clean-blog/index.md b/docs/content/themes/clean-blog/index.md index ff2718e7..d589d3b1 100644 --- a/docs/content/themes/clean-blog/index.md +++ b/docs/content/themes/clean-blog/index.md @@ -3,11 +3,11 @@ title = "Clean Blog" description = "A port of Start Bootstrap Clean Blog for Zola" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/dave-tucker/zola-clean-blog" homepage = "https://github.com/dave-tucker/zola-clean-blog" minimum_version = "0.4.0" diff --git a/docs/content/themes/clean-blog/screenshot.png b/docs/content/themes/clean-blog/screenshot.png deleted file mode 100644 index 394d23ea..00000000 Binary files a/docs/content/themes/clean-blog/screenshot.png and /dev/null differ diff --git a/docs/content/themes/codinfox-zola/index.md b/docs/content/themes/codinfox-zola/index.md index 7803bd4d..35388748 100644 --- a/docs/content/themes/codinfox-zola/index.md +++ b/docs/content/themes/codinfox-zola/index.md @@ -3,11 +3,11 @@ title = "codinfox-zola" description = "Codinfox theme for Zola" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/svavs/codinfox-zola" homepage = "https://github.com/svavs/codinfox-zola" minimum_version = "0.11.0" diff --git a/docs/content/themes/codinfox-zola/screenshot.png b/docs/content/themes/codinfox-zola/screenshot.png deleted file mode 100644 index 135ba71a..00000000 Binary files a/docs/content/themes/codinfox-zola/screenshot.png and /dev/null differ diff --git a/docs/content/themes/dinkleberg/index.md b/docs/content/themes/dinkleberg/index.md index d05f2d8a..8799011c 100644 --- a/docs/content/themes/dinkleberg/index.md +++ b/docs/content/themes/dinkleberg/index.md @@ -3,11 +3,11 @@ title = "dinkleberg" description = "The Rust BR theme for Gutenberg" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/rust-br/dinkleberg.git" homepage = "https://github.com/rust-br/dinkleberg" minimum_version = "0.4.0" diff --git a/docs/content/themes/dinkleberg/screenshot.png b/docs/content/themes/dinkleberg/screenshot.png deleted file mode 100644 index c19e68e2..00000000 Binary files a/docs/content/themes/dinkleberg/screenshot.png and /dev/null differ diff --git a/docs/content/themes/docsascode-theme/index.md b/docs/content/themes/docsascode-theme/index.md index 4c1b1673..e1c42729 100644 --- a/docs/content/themes/docsascode-theme/index.md +++ b/docs/content/themes/docsascode-theme/index.md @@ -3,11 +3,11 @@ title = "Docsascode_theme" description = "A modern simple Zola's theme related to docs as code methodology" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/codeandmedia/zola_docsascode_theme.git" homepage = "https://github.com/codeandmedia/zola_docsascode_theme" minimum_version = "0.10.0" @@ -29,6 +29,12 @@ The repo contains a theme for [Zola](https://www.getzola.org/) (the best static codeandmedia/docsascode-theme:latest ``` +If you would use Docker on MacBook M1 processors \ Raspberry Pi4 64bit \ Amazon Graviton or another ARM64 - just fork the ARM64 branch or push + +``` +codeandmedia/docsascode-theme-arm64:latest +``` + ## Perks * light / dark switcher diff --git a/docs/content/themes/docsascode-theme/screenshot.png b/docs/content/themes/docsascode-theme/screenshot.png deleted file mode 100644 index 2c27e8ef..00000000 Binary files a/docs/content/themes/docsascode-theme/screenshot.png and /dev/null differ diff --git a/docs/content/themes/even/index.md b/docs/content/themes/even/index.md index bf3265e4..2547cfe4 100644 --- a/docs/content/themes/even/index.md +++ b/docs/content/themes/even/index.md @@ -3,11 +3,11 @@ title = "even" description = "A robust, elegant dark theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/getzola/even.git" homepage = "https://github.com/getzola/even" minimum_version = "0.11.0" diff --git a/docs/content/themes/even/screenshot.png b/docs/content/themes/even/screenshot.png deleted file mode 100644 index 1acdd623..00000000 Binary files a/docs/content/themes/even/screenshot.png and /dev/null differ diff --git a/docs/content/themes/feather/index.md b/docs/content/themes/feather/index.md index 62f3131b..11b938be 100644 --- a/docs/content/themes/feather/index.md +++ b/docs/content/themes/feather/index.md @@ -3,11 +3,11 @@ title = "feather" description = "A modern blog theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/piedoom/feather" homepage = "https://github.com/piedoom/feather" minimum_version = "0.5.1" diff --git a/docs/content/themes/feather/screenshot.png b/docs/content/themes/feather/screenshot.png deleted file mode 100644 index bb54fef9..00000000 Binary files a/docs/content/themes/feather/screenshot.png and /dev/null differ diff --git a/docs/content/themes/float/index.md b/docs/content/themes/float/index.md index 7df85d9b..19e91ca3 100644 --- a/docs/content/themes/float/index.md +++ b/docs/content/themes/float/index.md @@ -3,11 +3,11 @@ title = "Float" description = "An elegant blog theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://gitlab.com/float-theme/float.git" homepage = "https://float-theme.netlify.app/" minimum_version = "0.11.0" diff --git a/docs/content/themes/float/screenshot.png b/docs/content/themes/float/screenshot.png deleted file mode 100644 index c4e7c1e3..00000000 Binary files a/docs/content/themes/float/screenshot.png and /dev/null differ diff --git a/docs/content/themes/hallo/index.md b/docs/content/themes/hallo/index.md index fb394d78..88f6280e 100644 --- a/docs/content/themes/hallo/index.md +++ b/docs/content/themes/hallo/index.md @@ -3,11 +3,11 @@ title = "hallo" description = "A single-page theme to introduce yourself." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/flyingP0tat0/zola-hallo.git" homepage = "https://github.com/janbaudisch/zola-hallo" minimum_version = "0.4.0" @@ -122,8 +122,8 @@ foreground = "#FFF" # text and portrait border hover = "#333" # link hover ``` -[build-img]: https://travis-ci.com/janbaudisch/zola-hallo.svg?branch=master -[build-url]: https://travis-ci.com/janbaudisch/zola-hallo +[build-img]: https://builds.sr.ht/~janbaudisch/zola-hallo.svg +[build-url]: https://builds.sr.ht/~janbaudisch/zola-hallo [demo-img]: https://img.shields.io/badge/demo-live-green.svg [demo-url]: https://zola-hallo.janbaudisch.dev [zola]: https://www.getzola.org diff --git a/docs/content/themes/hallo/screenshot.png b/docs/content/themes/hallo/screenshot.png deleted file mode 100644 index da242a0b..00000000 Binary files a/docs/content/themes/hallo/screenshot.png and /dev/null differ diff --git a/docs/content/themes/hyde/index.md b/docs/content/themes/hyde/index.md index c6270738..9820f46e 100644 --- a/docs/content/themes/hyde/index.md +++ b/docs/content/themes/hyde/index.md @@ -3,11 +3,11 @@ title = "hyde" description = "A classic blog theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/getzola/hyde.git" homepage = "https://github.com/getzola/hyde" minimum_version = "0.11.0" diff --git a/docs/content/themes/hyde/screenshot.png b/docs/content/themes/hyde/screenshot.png deleted file mode 100644 index 5e218059..00000000 Binary files a/docs/content/themes/hyde/screenshot.png and /dev/null differ diff --git a/docs/content/themes/juice/index.md b/docs/content/themes/juice/index.md index cf02f039..602d5733 100644 --- a/docs/content/themes/juice/index.md +++ b/docs/content/themes/juice/index.md @@ -3,11 +3,11 @@ title = "juice" description = "An intuitive, elegant, and lightweight Zola™ theme for product sites." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/huhu/juice" homepage = "https://github.com/huhu/juice" minimum_version = "0.11.0" diff --git a/docs/content/themes/juice/screenshot.png b/docs/content/themes/juice/screenshot.png deleted file mode 100644 index 3150b215..00000000 Binary files a/docs/content/themes/juice/screenshot.png and /dev/null differ diff --git a/docs/content/themes/lightspeed/index.md b/docs/content/themes/lightspeed/index.md index 1634bb15..bd9013d2 100644 --- a/docs/content/themes/lightspeed/index.md +++ b/docs/content/themes/lightspeed/index.md @@ -3,11 +3,11 @@ title = "lightspeed" description = "Zola theme with a perfect Lighthouse score" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/carpetscheme/lightspeed" homepage = "https://github.com/carpetscheme/lightspeed" minimum_version = "0.10.0" @@ -26,8 +26,9 @@ An insanely fast and performance-based Zola theme, ported from [Light Speed Jeky Some fun facts about the theme: * Perfect score on Google's Lighthouse audit -* Only ~600 bytes of CSS +* Only ~700 bytes of CSS * No JavaScript +* Now with SEO! Demo: [quirky-perlman-34d0da.netlify.com](https://quirky-perlman-34d0da.netlify.com) @@ -38,10 +39,10 @@ Demo: [quirky-perlman-34d0da.netlify.com](https://quirky-perlman-34d0da.netlify. - [Installation](#installation) - [Options](#options) - [Title](#title) - - [Sass](#Sass) - [Footer menu](#footer-menu) - - [Author](#author) - - [Netlify](#netlify) + - [SEO](#seo) + - [Footer text](#footer-text) + - [Sass](#Sass) - [Original](#original) - [License](#license) @@ -77,18 +78,6 @@ description = "for different folks" ``` -### Sass - -Styles are compiled from sass and imported inline to the header :zap: - -You can overide the styles by enabling sass compilation in the config: - -```toml -compile_sass = true -``` - -...and placing a replacement `style.scss` file in your sass folder. - ### Footer-menu Set a field in `extra` with a key of `footer_links`: @@ -97,7 +86,7 @@ Set a field in `extra` with a key of `footer_links`: footer_links = [ {url = "$BASE_URL/about", name = "About"}, - {url = "$BASE_URL/rss.xml", name = "RSS"}, + {url = "$BASE_URL/atom.xml", name = "RSS"}, {url = "https://google.com", name = "Google"}, ] ``` @@ -111,32 +100,45 @@ Create pages such as `$BASE_URL/about` by placing them in a subfolder of the con path = "about" ``` -### Author +### SEO -To add author name to the head meta-data, set an `author` field in `extra`: +Most SEO tags are populated by the page metadata, but you can set the `author` and for the `og:image` tag provide the path to an image: ```toml [extra] author = "Grant Green" +ogimage = "Greenery.png" ``` -### Netlify +### Footer-text -Deployed on netlify? Add a link in the footer by setting `netlify` in `extra` as `true`. +By default the footer provides links to Zola and Netlify, and a tagline of "Maintained with :heart: for the web". +To disable any of those parts, and/or add a custom tagline of your own, the following options are available: ```toml [extra] -netlify = true +zola = true +netlify = false +maintained_with_love = false +footer_tagline = "What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet." ``` +### Sass + +Styles are compiled from sass and imported inline to the header :zap: + +You can overide the styles by enabling sass compilation in the config: + +```toml +compile_sass = true +``` + +...and placing a replacement `style.scss` file in your sass folder. + ## Original -This template is based on the Jekyll template [Light Speed Jekyll](https://github.com/bradleytaunt/lightspeed) by **Bradley Taunt**: - -- -- - +This template is based on the Jekyll template [Light Speed Jekyll](https://github.com/bradleytaunt/lightspeed) by Bradley Taunt. ## License diff --git a/docs/content/themes/lightspeed/screenshot.png b/docs/content/themes/lightspeed/screenshot.png deleted file mode 100644 index 6070f1ee..00000000 Binary files a/docs/content/themes/lightspeed/screenshot.png and /dev/null differ diff --git a/docs/content/themes/oceanic-zen/index.md b/docs/content/themes/oceanic-zen/index.md index 60c2f920..3fc5e8cb 100644 --- a/docs/content/themes/oceanic-zen/index.md +++ b/docs/content/themes/oceanic-zen/index.md @@ -3,11 +3,11 @@ title = "Oceanic Zen" description = "Minimalistic blog theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/barlog-m/oceanic-zen.git" homepage = "https://github.com/barlog-m/oceanic-zen" minimum_version = "0.9.0" diff --git a/docs/content/themes/oceanic-zen/screenshot.png b/docs/content/themes/oceanic-zen/screenshot.png deleted file mode 100644 index 430750ff..00000000 Binary files a/docs/content/themes/oceanic-zen/screenshot.png and /dev/null differ diff --git a/docs/content/themes/sam/index.md b/docs/content/themes/sam/index.md index efe49ba1..26712749 100644 --- a/docs/content/themes/sam/index.md +++ b/docs/content/themes/sam/index.md @@ -3,11 +3,11 @@ title = "sam" description = "A Simple and Minimalist theme with a focus on typography and content." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/janbaudisch/zola-sam.git" homepage = "https://github.com/janbaudisch/zola-sam" minimum_version = "0.4.0" @@ -154,8 +154,8 @@ To place some text at the end of pages, set the following: text = "Some footer text." ``` -[build-img]: https://travis-ci.com/janbaudisch/zola-sam.svg?branch=master -[build-url]: https://travis-ci.com/janbaudisch/zola-sam +[build-img]: https://builds.sr.ht/~janbaudisch/zola-sam.svg +[build-url]: https://builds.sr.ht/~janbaudisch/zola-sam [demo-img]: https://img.shields.io/badge/demo-live-green.svg [demo-url]: https://zola-sam.janbaudisch.dev [zola]: https://getzola.org diff --git a/docs/content/themes/sam/screenshot.png b/docs/content/themes/sam/screenshot.png deleted file mode 100644 index 81e8c683..00000000 Binary files a/docs/content/themes/sam/screenshot.png and /dev/null differ diff --git a/docs/content/themes/simple-dev-blog/index.md b/docs/content/themes/simple-dev-blog/index.md index 65fc716a..0a09aeac 100644 --- a/docs/content/themes/simple-dev-blog/index.md +++ b/docs/content/themes/simple-dev-blog/index.md @@ -3,11 +3,11 @@ title = "simple-dev-blog" description = "A simple dev blog theme with no javascript, prerendered linked pages and SEO tags." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/bennetthardwick/simple-dev-blog-zola-starter" homepage = "https://github.com/bennetthardwick/simple-dev-blog-zola-starter" minimum_version = "0.4.0" @@ -19,16 +19,15 @@ name = "Bennett Hardwick" homepage = "https://bennetthardwick.com/" +++ - ![preview image](https://i.imgur.com/IWoJtkF.png) # simple-dev-blog-zola-starter -A simple dev-blog theme for Zola. It uses no JavaScript, prerenders links between navigation, blog posts and tags and adds common tags for SEO. +A simple dev-blog theme for Zola. It uses no JavaScript, prerenders links between navigation, blog posts and tags and adds common tags for SEO. You can view it live [here](https://simple-dev-blog-zola-starter.netlify.app/). -### How to get started +## How to get started To create a new Zola site, first download the CLI and install it on your system. You can find installation instructions [on the Zola website](https://www.getzola.org/documentation/getting-started/installation/). @@ -50,7 +49,11 @@ You can find installation instructions [on the Zola website](https://www.getzola 3. Now in your `config.toml` file, choose the theme by setting `theme = "simple-dev-blog"`. -4. That's it! Now build your site by running the following command, and navigate to `127.0.0.1:111`: +4. This theme uses the `tags` taxonomy, in your `config.toml` file set `taxonomies = [ { name = "tags" } ]` + +5. Copy across the default content from the theme by running `cp themes/simple-dev-blog/content/* ./content -r` + +6. That's it! Now build your site by running the following command, and navigate to `127.0.0.1:111`: ```sh zola serve @@ -58,5 +61,30 @@ You can find installation instructions [on the Zola website](https://www.getzola You should now have a speedy simple dev blog up and running, have fun! +## Customisation + +Look at the `config.toml` and `theme.toml` in this repo for an idea, here's a list of all the options: + +### Global + +The following options should be under the `[extra]` in `config.toml` + +- `accent_light` - a lighter shade of your site's accent color +- `accent` - your site's accent color +- `blog_path` - the path to your blog (defaults to `blog`) +- `default_og_image` - the path default og:image for your page +- `footer_about` - the content for your footer in markdown +- `icon` - the path to the icon for your site in the content folder + - E.g to add the file `icon.png` you should put it in `content/icon.png` +- `nav` - see `theme.toml`, the navigation links for your site +- `not_found_message` - the content for your 404 page in markdown +- `profile_large` - the path to a larger vertical version of your profile picture in the content folder +- `profile_small` - the path to a small version of your profile picture in the content folder + +### Page + +The following options should be under the `[extra]` section of each page + +- `thumbnail` - the path to your og:image for that page \ No newline at end of file diff --git a/docs/content/themes/simple-dev-blog/screenshot.png b/docs/content/themes/simple-dev-blog/screenshot.png deleted file mode 100644 index c5ecdfab..00000000 Binary files a/docs/content/themes/simple-dev-blog/screenshot.png and /dev/null differ diff --git a/docs/content/themes/slim/index.md b/docs/content/themes/slim/index.md index 499060bc..cb5466bf 100644 --- a/docs/content/themes/slim/index.md +++ b/docs/content/themes/slim/index.md @@ -3,11 +3,11 @@ title = "Slim" description = "Slim is a minimal, clean and beautiful theme for Zola." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/jameshclrk/zola-slim" homepage = "https://github.com/jameshclrk/zola-slim" minimum_version = "0.8.0" diff --git a/docs/content/themes/slim/screenshot.png b/docs/content/themes/slim/screenshot.png deleted file mode 100644 index 5c5c8522..00000000 Binary files a/docs/content/themes/slim/screenshot.png and /dev/null differ diff --git a/docs/content/themes/solar-theme-zola/index.md b/docs/content/themes/solar-theme-zola/index.md index b9e7e81d..26865258 100644 --- a/docs/content/themes/solar-theme-zola/index.md +++ b/docs/content/themes/solar-theme-zola/index.md @@ -3,11 +3,11 @@ title = "solar-theme-zola" description = "A port of solar-theme-hugo for zola" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/hulufei/solar-theme-zola.git" homepage = "https://github.com/hulufei/solar-theme-zola" minimum_version = "0.4.0" diff --git a/docs/content/themes/solar-theme-zola/screenshot.png b/docs/content/themes/solar-theme-zola/screenshot.png deleted file mode 100644 index 05186b54..00000000 Binary files a/docs/content/themes/solar-theme-zola/screenshot.png and /dev/null differ diff --git a/docs/content/themes/toucan/index.md b/docs/content/themes/toucan/index.md index 6c5d5033..0d68d794 100644 --- a/docs/content/themes/toucan/index.md +++ b/docs/content/themes/toucan/index.md @@ -3,11 +3,11 @@ title = "Toucan" description = "Inspired from Pelican default theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://git.42l.fr/HugoTrentesaux/toucan.git" homepage = "https://git.42l.fr/HugoTrentesaux/toucan" minimum_version = "0.8.0" diff --git a/docs/content/themes/toucan/screenshot.png b/docs/content/themes/toucan/screenshot.png deleted file mode 100644 index 87287b0f..00000000 Binary files a/docs/content/themes/toucan/screenshot.png and /dev/null differ diff --git a/docs/content/themes/zerm/index.md b/docs/content/themes/zerm/index.md index 79e36f21..05dc2a06 100644 --- a/docs/content/themes/zerm/index.md +++ b/docs/content/themes/zerm/index.md @@ -3,11 +3,11 @@ title = "zerm" description = "A minimalistic and dark theme based on Radek Kozieł's theme for Hugo" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/ejmg/zerm.git" homepage = "https://github.com/ejmg/zerm" minimum_version = "0.8.0" diff --git a/docs/content/themes/zerm/screenshot.png b/docs/content/themes/zerm/screenshot.png deleted file mode 100644 index 18513991..00000000 Binary files a/docs/content/themes/zerm/screenshot.png and /dev/null differ diff --git a/docs/content/themes/zola-henry/index.md b/docs/content/themes/zola-henry/index.md index ce0b153d..d5ac383a 100644 --- a/docs/content/themes/zola-henry/index.md +++ b/docs/content/themes/zola-henry/index.md @@ -3,11 +3,11 @@ title = "henry" description = "A timeless blog theme" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/sirodoht/zola-henry" homepage = "https://github.com/sirodoht/zola-henry" minimum_version = "0.4.0" @@ -65,6 +65,15 @@ By default Henry ships with GitHub icon link in the right side of the footer. Yo henry_github = "https://github.com/sirodoht/zola-henry" ``` +### Footer Twitter icon link + +Twitter is too mainstream and a bit lame, but 100% of our users have requested, so we offer it. + +```toml +[extra] +henry_twitter = "https://twitter.com/dhh" +``` + ## License MIT diff --git a/docs/content/themes/zola-henry/screenshot.png b/docs/content/themes/zola-henry/screenshot.png deleted file mode 100644 index f12cfa58..00000000 Binary files a/docs/content/themes/zola-henry/screenshot.png and /dev/null differ diff --git a/docs/content/themes/zola-paper/index.md b/docs/content/themes/zola-paper/index.md index eeff9848..a2538d36 100644 --- a/docs/content/themes/zola-paper/index.md +++ b/docs/content/themes/zola-paper/index.md @@ -3,11 +3,11 @@ title = "zola-paper" description = "A clean theme inspired from hugo-paper." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/schoenenberg/zola-paper.git" homepage = "https://github.com/schoenenberg/zola-paper" minimum_version = "0.11.0" diff --git a/docs/content/themes/zola-paper/screenshot.png b/docs/content/themes/zola-paper/screenshot.png deleted file mode 100644 index 91973a42..00000000 Binary files a/docs/content/themes/zola-paper/screenshot.png and /dev/null differ diff --git a/docs/content/themes/zola-pickles/index.md b/docs/content/themes/zola-pickles/index.md index ef78d2cb..e8c835e3 100644 --- a/docs/content/themes/zola-pickles/index.md +++ b/docs/content/themes/zola-pickles/index.md @@ -3,11 +3,11 @@ title = "pickles" description = "A modern, simple, clean blog theme for Zola." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/lukehsiao/zola-pickles.git" homepage = "https://github.com/lukehsiao/zola-pickles" minimum_version = "0.11.0" @@ -16,7 +16,7 @@ demo = "" [extra.author] name = "Luke Hsiao" -homepage = "https://www.lukehsiao.com" +homepage = "https://luke.hsiao.dev" +++ # Pickles diff --git a/docs/content/themes/zola-pickles/screenshot.png b/docs/content/themes/zola-pickles/screenshot.png deleted file mode 100644 index 0e35c36c..00000000 Binary files a/docs/content/themes/zola-pickles/screenshot.png and /dev/null differ diff --git a/docs/content/themes/zola-theme-hikari/index.md b/docs/content/themes/zola-theme-hikari/index.md index 276c92d6..02463f6a 100644 --- a/docs/content/themes/zola-theme-hikari/index.md +++ b/docs/content/themes/zola-theme-hikari/index.md @@ -3,11 +3,11 @@ title = "Hikari" description = "Fluid, responsive blog theme for Zola" template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/waynee95/zola-theme-hikari" homepage = "https://github.com/waynee95/zola-theme-hikari" minimum_version = "0.5.1" diff --git a/docs/content/themes/zola-theme-hikari/screenshot.png b/docs/content/themes/zola-theme-hikari/screenshot.png deleted file mode 100644 index 359baf41..00000000 Binary files a/docs/content/themes/zola-theme-hikari/screenshot.png and /dev/null differ diff --git a/docs/content/themes/zola.386/index.md b/docs/content/themes/zola.386/index.md index 1110c0d1..32b5d082 100644 --- a/docs/content/themes/zola.386/index.md +++ b/docs/content/themes/zola.386/index.md @@ -3,14 +3,14 @@ title = "zola.386" description = "Zola port of the BOOTSTRA.386 theme." template = "theme.html" -date = 2020-12-08T16:58:54+01:00 +date = 2020-12-14T20:45:47+01:00 [extra] -created = 2020-12-08T16:58:54+01:00 -updated = 2020-12-08T16:58:54+01:00 +created = 2020-12-14T20:45:47+01:00 +updated = 2020-12-14T20:45:47+01:00 repository = "https://github.com/lopes/zola.386" homepage = "https://github.com/lopes/zola.386" -minimum_version = "0.1.3" +minimum_version = "0.10.1" license = "MIT" demo = "https://zola-386.netlify.com" @@ -35,7 +35,7 @@ ZOLA.386 is a port of the BOOTSTRA.386 theme and was based on: ZOLA.386 is a theme that refers to the 90s, but with cutting edge features to be fast and responsive. -## Instalation +## Installation The easiest way to install ZOLA.386 is to clone this repository and build your site upon it: ```bash @@ -46,7 +46,7 @@ Of course you can install it just as another theme for your site, but ZOLA.386 m ```bash $ cd themes -$ git clone https://github.com/lopes/zola.386.git +$ git submodule add https://github.com/lopes/zola.386 ``` @@ -82,16 +82,17 @@ zola386_menu = [ ### Social ZOLA.386 is also prepared to deal with Google Analytics, Disqus, and Twitter --[Open Graph Protocol](https://ogp.me/) is welcome. This theme is prepared to use the output of [Favicon Generator](https://www.favicon-generator.org/), to do so, you'll just need to download the output of that site and extract in `static/images`. -As said, Disqus is supportted, but besides setting the username in `config.toml`, you also must to put a `disqus = true` extra option on the pages where Disqus will be enable --this gives you the freedom to enable or disable comments on certain posts. You can use the extra option `image` on each page, to represent that post. +As said, Disqus is supportted, but besides setting the username in `config.toml`, you also must to put a `comments = true` extra option on the pages where Disqus will be enabled --this gives you the freedom to enable or disable comments on certain posts. You can use the extra option `image` on each page, to represent that post. ### Animations All JavaScript animations can be set at `static/js/zola386.js`. Basically you can disable all animations, use one or two scans, and change the scan speed. Personally, I prefer only one scan with a speed factor of 5. - ### Language - Under the `label_` variables, you can set names to better localize your site. Note that you can change the language of a single page, by using `page.extra.lang`, which causes `` to change only on that page. A theme to provide information for its owner and SEO-friendly. +### Search +Search was implemented according to the [official documentation](https://www.getzola.org/documentation/content/search/). It uses JavaScript to search on an indexed version of the site based on `search_index.LANG.js`, `elasticlunr.min.js`, and `search.js` --the first two are generated after each build. If you're running your site in other default language other than English, you **must** change the `search_index.LANG.js` line in `index.html`, setting up `LANG` accordingly. + ### Other files The `content\_index.md` file must be properly configured to provide better experience. Check out this file for more information. diff --git a/docs/content/themes/zola.386/screenshot.png b/docs/content/themes/zola.386/screenshot.png index ca4f7149..ba6ba699 100644 Binary files a/docs/content/themes/zola.386/screenshot.png and b/docs/content/themes/zola.386/screenshot.png differ diff --git a/snapcraft.yaml b/snapcraft.yaml index 5a904400..64adfd67 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,5 +1,5 @@ name: zola -version: 0.12.0 +version: 0.13.0 summary: A fast static site generator in a single binary with everything built-in. description: | A fast static site generator in a single binary with everything built-in. @@ -21,7 +21,7 @@ parts: zola: source-type: git source: https://github.com/getzola/zola.git - source-tag: v0.12.0 + source-tag: v0.13.0 plugin: rust rust-channel: stable build-packages: diff --git a/src/cli.rs b/src/cli.rs index bc14a5ab..ab1321f9 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -44,7 +44,6 @@ pub fn build_cli() -> App<'static, 'static> { Arg::with_name("output_dir") .short("o") .long("output-dir") - .default_value("public") .takes_value(true) .help("Outputs the generated site in the given path"), Arg::with_name("drafts") @@ -68,7 +67,6 @@ pub fn build_cli() -> App<'static, 'static> { Arg::with_name("output_dir") .short("o") .long("output-dir") - .default_value("public") .takes_value(true) .help("Outputs the generated site in the given path"), Arg::with_name("base_url") @@ -77,10 +75,6 @@ pub fn build_cli() -> App<'static, 'static> { .default_value("127.0.0.1") .takes_value(true) .help("Changes the base_url"), - Arg::with_name("watch_only") - .long("watch-only") - .takes_value(false) - .help("Do not start a server, just re-build project on changes"), Arg::with_name("drafts") .long("drafts") .takes_value(false) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 3a2c7634..7a0e85cb 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -9,11 +9,13 @@ pub fn build( root_dir: &Path, config_file: &Path, base_url: Option<&str>, - output_dir: &Path, + output_dir: Option<&Path>, include_drafts: bool, ) -> Result<()> { let mut site = Site::new(root_dir, config_file)?; - site.set_output_path(output_dir); + if let Some(output_dir) = output_dir { + site.set_output_path(output_dir); + } if let Some(b) = base_url { site.set_base_url(b.to_string()); } diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 07f230e5..1a381737 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -15,13 +15,14 @@ base_url = "%BASE_URL%" # Whether to automatically compile all Sass files in the sass directory compile_sass = %COMPILE_SASS% +# Whether to build a search index to be used later on by a JavaScript library +build_search_index = %SEARCH% + +[markdown] # Whether to do syntax highlighting # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola highlight_code = %HIGHLIGHT% -# Whether to build a search index to be used later on by a JavaScript library -build_search_index = %SEARCH% - [extra] # Put all your custom variables here "#; diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 2f2f299a..39ab47f9 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -22,16 +22,16 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. use std::fs::{read_dir, remove_dir_all}; +use std::net::{SocketAddrV4, TcpListener}; use std::path::{Path, PathBuf}; use std::sync::mpsc::channel; use std::thread; use std::time::{Duration, Instant}; -use std::net::{SocketAddrV4, TcpListener}; use hyper::header; +use hyper::server::Server; use hyper::service::{make_service_fn, service_fn}; -use hyper::{Body, Method, Request, Response, Server, StatusCode}; -use hyper_staticfile::ResolveResult; +use hyper::{Body, Method, Request, Response, StatusCode}; use chrono::prelude::*; use notify::{watcher, RecursiveMode, Watcher}; @@ -70,10 +70,15 @@ static NOT_FOUND_TEXT: &[u8] = b"Not Found"; // This is dist/livereload.min.js from the LiveReload.js v3.2.4 release const LIVE_RELOAD: &str = include_str!("livereload.js"); -async fn handle_request(req: Request, root: PathBuf) -> Result> { +async fn handle_request(req: Request, mut root: PathBuf) -> Result> { let mut path = RelativePathBuf::new(); + // https://zola.discourse.group/t/percent-encoding-for-slugs/736 + let decoded = match percent_encoding::percent_decode_str(req.uri().path()).decode_utf8() { + Ok(d) => d, + Err(_) => return Ok(not_found()), + }; - for c in req.uri().path().split('/') { + for c in decoded.split('/') { path.push(c); } @@ -90,18 +95,37 @@ async fn handle_request(req: Request, root: PathBuf) -> Result return Ok(method_not_allowed()), - ResolveResult::NotFound | ResolveResult::UriNotMatched => { - let not_found_path = RelativePath::new("404.html"); - let content_404 = SITE_CONTENT.read().unwrap().get(not_found_path).cloned(); - return Ok(not_found(content_404)); - } - _ => (), + // Handle only `GET`/`HEAD` requests + match *req.method() { + Method::HEAD | Method::GET => {} + _ => return Ok(method_not_allowed()), + } + + // Handle only simple path requests + if req.uri().scheme_str().is_some() || req.uri().host().is_some() { + return Ok(not_found()); + } + + // Remove the trailing slash from the request path + // otherwise `PathBuf` will interpret it as an absolute path + root.push(&req.uri().path()[1..]); + let result = tokio::fs::read(root).await; + + let contents = match result { + Err(err) => match err.kind() { + std::io::ErrorKind::NotFound => return Ok(not_found()), + std::io::ErrorKind::PermissionDenied => { + return Ok(Response::builder() + .status(StatusCode::FORBIDDEN) + .body(Body::empty()) + .unwrap()) + } + _ => panic!("{}", err), + }, + Ok(contents) => contents, }; - Ok(hyper_staticfile::ResponseBuilder::new().request(&req).build(result).unwrap()) + Ok(Response::builder().status(StatusCode::OK).body(Body::from(contents)).unwrap()) } fn livereload_js() -> Response { @@ -128,7 +152,10 @@ fn method_not_allowed() -> Response { .expect("Could not build Method Not Allowed response") } -fn not_found(content: Option) -> Response { +fn not_found() -> Response { + let not_found_path = RelativePath::new("404.html"); + let content = SITE_CONTENT.read().unwrap().get(not_found_path).cloned(); + if let Some(body) = content { return Response::builder() .header(header::CONTENT_TYPE, "text/html") @@ -145,25 +172,23 @@ fn not_found(content: Option) -> Response { .expect("Could not build Not Found response") } -fn rebuild_done_handling(broadcaster: &Option, res: Result<()>, reload_path: &str) { +fn rebuild_done_handling(broadcaster: &Sender, res: Result<()>, reload_path: &str) { match res { Ok(_) => { - if let Some(broadcaster) = broadcaster.as_ref() { - broadcaster - .send(format!( - r#" - {{ - "command": "reload", - "path": "{}", - "originalPath": "", - "liveCSS": true, - "liveImg": true, - "protocol": ["http://livereload.com/protocols/official-7"] - }}"#, - reload_path - )) - .unwrap(); - } + broadcaster + .send(format!( + r#" + {{ + "command": "reload", + "path": {}, + "originalPath": "", + "liveCSS": true, + "liveImg": true, + "protocol": ["http://livereload.com/protocols/official-7"] + }}"#, + serde_json::to_string(&reload_path).unwrap() + )) + .unwrap(); } Err(e) => console::unravel_errors("Failed to build the site", &e), } @@ -173,7 +198,7 @@ fn create_new_site( root_dir: &Path, interface: &str, interface_port: u16, - output_dir: &Path, + output_dir: Option<&Path>, base_url: &str, config_file: &Path, include_drafts: bool, @@ -192,7 +217,9 @@ fn create_new_site( site.enable_serve_mode(); site.set_base_url(base_url); - site.set_output_path(output_dir); + if let Some(output_dir) = output_dir { + site.set_output_path(output_dir); + } if include_drafts { site.include_drafts(); } @@ -212,10 +239,9 @@ pub fn serve( root_dir: &Path, interface: &str, interface_port: u16, - output_dir: &Path, + output_dir: Option<&Path>, base_url: &str, config_file: &Path, - watch_only: bool, open: bool, include_drafts: bool, fast_rebuild: bool, @@ -236,7 +262,7 @@ pub fn serve( // Stop right there if we can't bind to the address let bind_address: SocketAddrV4 = address.parse().unwrap(); if (TcpListener::bind(&bind_address)).is_err() { - return Err(format!("Cannot start server on address {}.", address))?; + return Err(format!("Cannot start server on address {}.", address).into()); } // An array of (path, bool, bool) where the path should be watched for changes, and the boolean value @@ -265,7 +291,7 @@ pub fn serve( let should_watch = match mode { WatchMode::Required => true, WatchMode::Optional => watch_path.exists(), - WatchMode::Condition(b) => b, + WatchMode::Condition(b) => b && watch_path.exists(), }; if should_watch { watcher @@ -277,18 +303,17 @@ pub fn serve( let ws_port = site.live_reload; let ws_address = format!("{}:{}", interface, ws_port.unwrap()); - let output_path = Path::new(output_dir).to_path_buf(); + let output_path = site.output_path.clone(); // output path is going to need to be moved later on, so clone it for the // http closure to avoid contention. let static_root = output_path.clone(); - let broadcaster = if !watch_only { + let broadcaster = { thread::spawn(move || { let addr = address.parse().unwrap(); - let mut rt = tokio::runtime::Builder::new() + let rt = tokio::runtime::Builder::new_current_thread() .enable_all() - .basic_scheduler() .build() .expect("Could not build tokio runtime"); @@ -345,10 +370,7 @@ pub fn serve( ws_server.run().unwrap(); }); - Some(broadcaster) - } else { - println!("Watching in watch only mode, no web server will be started"); - None + broadcaster }; println!("Listening for changes in {}{{{}}}", root_dir.display(), watchers.join(", ")); @@ -440,10 +462,7 @@ pub fn serve( loop { match rx.recv() { Ok(event) => { - let can_do_fast_reload = match event { - Remove(_) => false, - _ => true, - }; + let can_do_fast_reload = !matches!(event, Remove(_)); match event { // Intellij does weird things on edit, chmod is there to count those changes @@ -503,10 +522,8 @@ pub fn serve( site = s; } } - } else { - if let Some(s) = recreate_site() { - site = s; - } + } else if let Some(s) = recreate_site() { + site = s; } } (ChangeKind::Templates, partial_path) => { diff --git a/src/main.rs b/src/main.rs index 3eec3ba3..7bff8282 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::env; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::Instant; use utils::net::{get_available_port, port_is_available}; @@ -37,12 +37,12 @@ fn main() { ("build", Some(matches)) => { console::info("Building site..."); let start = Instant::now(); - let output_dir = PathBuf::from(matches.value_of("output_dir").unwrap()); + let output_dir = matches.value_of("output_dir").map(|output_dir| Path::new(output_dir)); match cmd::build( &root_dir, &config_file, matches.value_of("base_url"), - &output_dir, + output_dir, matches.is_present("drafts"), ) { Ok(()) => console::report_elapsed_time(start), @@ -61,18 +61,17 @@ fn main() { ::std::process::exit(1); } }; - let watch_only = matches.is_present("watch_only"); let open = matches.is_present("open"); let include_drafts = matches.is_present("drafts"); let fast = matches.is_present("fast"); // Default one - if port != 1111 && !watch_only && !port_is_available(port) { + if port != 1111 && !port_is_available(port) { console::error("The requested port is not available"); ::std::process::exit(1); } - if !watch_only && !port_is_available(port) { + if !port_is_available(port) { port = if let Some(p) = get_available_port(1111) { p } else { @@ -80,17 +79,16 @@ fn main() { ::std::process::exit(1); } } - let output_dir = PathBuf::from(matches.value_of("output_dir").unwrap()); + let output_dir = matches.value_of("output_dir").map(|output_dir| Path::new(output_dir)); let base_url = matches.value_of("base_url").unwrap(); console::info("Building site..."); match cmd::serve( &root_dir, interface, port, - &output_dir, + output_dir, base_url, &config_file, - watch_only, open, include_drafts, fast, diff --git a/sublime/syntaxes/GraphQL-SublimeText3 b/sublime/syntaxes/GraphQL-SublimeText3 deleted file mode 160000 index c9d84587..00000000 --- a/sublime/syntaxes/GraphQL-SublimeText3 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c9d84587eb1a6eb34457a875f21b9b1a29306be3 diff --git a/sublime/syntaxes/Julia-sublime b/sublime/syntaxes/Julia-sublime deleted file mode 160000 index 6c0d770f..00000000 --- a/sublime/syntaxes/Julia-sublime +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6c0d770fc74e6bc037c70cae1f94fe113b60fd95 diff --git a/sublime/syntaxes/LESS-sublime b/sublime/syntaxes/LESS-sublime deleted file mode 160000 index 44632e19..00000000 --- a/sublime/syntaxes/LESS-sublime +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 44632e19af8370b39643dd60cd76deb7a13c63ee diff --git a/sublime/syntaxes/Packages b/sublime/syntaxes/Packages index f36b8f80..207cf862 160000 --- a/sublime/syntaxes/Packages +++ b/sublime/syntaxes/Packages @@ -1 +1 @@ -Subproject commit f36b8f807d5f30d2b8ef639232a9fc5960f550fa +Subproject commit 207cf86237429d3e5ffdf40223283de7bdc206fb diff --git a/sublime/syntaxes/Sublime-CMakeLists b/sublime/syntaxes/Sublime-CMakeLists deleted file mode 160000 index aba96a08..00000000 --- a/sublime/syntaxes/Sublime-CMakeLists +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aba96a0862369e9f960bb63a38e2d7563ea6475e diff --git a/sublime/syntaxes/SublimeSass b/sublime/syntaxes/SublimeSass deleted file mode 160000 index 478d3113..00000000 --- a/sublime/syntaxes/SublimeSass +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 478d3113b82253c08052421595dbf6372120f80f diff --git a/sublime/syntaxes/awk-sublime b/sublime/syntaxes/awk-sublime deleted file mode 160000 index 1ce5f90d..00000000 --- a/sublime/syntaxes/awk-sublime +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1ce5f90d444d80b12af41bc051507e914730d4ef diff --git a/sublime/syntaxes/elixir-sublime-syntax b/sublime/syntaxes/elixir-sublime-syntax deleted file mode 160000 index d223f676..00000000 --- a/sublime/syntaxes/elixir-sublime-syntax +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d223f67612fcc3ee2edd3336ffc285a9ee673406 diff --git a/sublime/syntaxes/Assembly x86.sublime-syntax b/sublime/syntaxes/extra/Assembly x86.sublime-syntax similarity index 100% rename from sublime/syntaxes/Assembly x86.sublime-syntax rename to sublime/syntaxes/extra/Assembly x86.sublime-syntax diff --git a/sublime/syntaxes/CSV.sublime-syntax b/sublime/syntaxes/extra/CSV.sublime-syntax similarity index 100% rename from sublime/syntaxes/CSV.sublime-syntax rename to sublime/syntaxes/extra/CSV.sublime-syntax diff --git a/sublime/syntaxes/Crystal.sublime-syntax b/sublime/syntaxes/extra/Crystal.sublime-syntax similarity index 100% rename from sublime/syntaxes/Crystal.sublime-syntax rename to sublime/syntaxes/extra/Crystal.sublime-syntax diff --git a/sublime/syntaxes/Dart.sublime-syntax b/sublime/syntaxes/extra/Dart.sublime-syntax similarity index 100% rename from sublime/syntaxes/Dart.sublime-syntax rename to sublime/syntaxes/extra/Dart.sublime-syntax diff --git a/sublime/syntaxes/Docker.tmbundle b/sublime/syntaxes/extra/Docker.tmbundle similarity index 100% rename from sublime/syntaxes/Docker.tmbundle rename to sublime/syntaxes/extra/Docker.tmbundle diff --git a/sublime/syntaxes/GDScript-sublime b/sublime/syntaxes/extra/GDScript-sublime similarity index 100% rename from sublime/syntaxes/GDScript-sublime rename to sublime/syntaxes/extra/GDScript-sublime diff --git a/sublime/syntaxes/extra/GraphQL-SublimeText3 b/sublime/syntaxes/extra/GraphQL-SublimeText3 new file mode 160000 index 00000000..59304d6c --- /dev/null +++ b/sublime/syntaxes/extra/GraphQL-SublimeText3 @@ -0,0 +1 @@ +Subproject commit 59304d6c7b5019091b532a3197251e393e1db7b2 diff --git a/sublime/syntaxes/Handlebars.sublime-syntax b/sublime/syntaxes/extra/Handlebars.sublime-syntax similarity index 100% rename from sublime/syntaxes/Handlebars.sublime-syntax rename to sublime/syntaxes/extra/Handlebars.sublime-syntax diff --git a/sublime/syntaxes/extra/Julia-sublime b/sublime/syntaxes/extra/Julia-sublime new file mode 160000 index 00000000..e2b1cb54 --- /dev/null +++ b/sublime/syntaxes/extra/Julia-sublime @@ -0,0 +1 @@ +Subproject commit e2b1cb549d57368b7b22e79430a1d5f47555e802 diff --git a/sublime/syntaxes/Kotlin.sublime-syntax b/sublime/syntaxes/extra/Kotlin.sublime-syntax similarity index 100% rename from sublime/syntaxes/Kotlin.sublime-syntax rename to sublime/syntaxes/extra/Kotlin.sublime-syntax diff --git a/sublime/syntaxes/extra/LESS-sublime b/sublime/syntaxes/extra/LESS-sublime new file mode 160000 index 00000000..a2eae045 --- /dev/null +++ b/sublime/syntaxes/extra/LESS-sublime @@ -0,0 +1 @@ +Subproject commit a2eae0453ed062dd499e30f561bc33bbeb5804b4 diff --git a/sublime/syntaxes/MZN.sublime-syntax b/sublime/syntaxes/extra/MZN.sublime-syntax similarity index 100% rename from sublime/syntaxes/MZN.sublime-syntax rename to sublime/syntaxes/extra/MZN.sublime-syntax diff --git a/sublime/syntaxes/Nim.sublime-syntax b/sublime/syntaxes/extra/Nim.sublime-syntax similarity index 100% rename from sublime/syntaxes/Nim.sublime-syntax rename to sublime/syntaxes/extra/Nim.sublime-syntax diff --git a/sublime/syntaxes/Nix.sublime-syntax b/sublime/syntaxes/extra/Nix.sublime-syntax similarity index 100% rename from sublime/syntaxes/Nix.sublime-syntax rename to sublime/syntaxes/extra/Nix.sublime-syntax diff --git a/sublime/syntaxes/PowerShell.sublime-syntax b/sublime/syntaxes/extra/PowerShell.sublime-syntax similarity index 100% rename from sublime/syntaxes/PowerShell.sublime-syntax rename to sublime/syntaxes/extra/PowerShell.sublime-syntax diff --git a/sublime/syntaxes/Prolog.sublime-syntax b/sublime/syntaxes/extra/Prolog.sublime-syntax similarity index 100% rename from sublime/syntaxes/Prolog.sublime-syntax rename to sublime/syntaxes/extra/Prolog.sublime-syntax diff --git a/sublime/syntaxes/README.md b/sublime/syntaxes/extra/README.md similarity index 92% rename from sublime/syntaxes/README.md rename to sublime/syntaxes/extra/README.md index 1478f809..b065b5d9 100644 --- a/sublime/syntaxes/README.md +++ b/sublime/syntaxes/extra/README.md @@ -14,5 +14,6 @@ are converted from the following repos at the following commit: - Reason: https://github.com/reasonml-editor/sublime-reason/tree/69925396ec6e73581357c0b1c487055fa6c065e8 - Stylus: https://github.com/billymoon/Stylus/tree/30908e3b5757d6cab4bf2ce660ef89b0c614cf62 - Racket: https://gist.githubusercontent.com/sliminality/3f1527f8e910c36b3303346422b03409/raw/9ce1ddd463c9bc97439726fd5f63b1fb3a36419b/Racket.tmLanguage +- TypeScript: https://github.com/microsoft/TypeScript-Sublime-Plugin/commit/a607ddfec90648c1c2f33f8306733f6aec5d2b78 The others, I haven't kept track of the repo/commit. diff --git a/sublime/syntaxes/Racket.sublime-syntax b/sublime/syntaxes/extra/Racket.sublime-syntax similarity index 100% rename from sublime/syntaxes/Racket.sublime-syntax rename to sublime/syntaxes/extra/Racket.sublime-syntax diff --git a/sublime/syntaxes/Reason.sublime-syntax b/sublime/syntaxes/extra/Reason.sublime-syntax similarity index 100% rename from sublime/syntaxes/Reason.sublime-syntax rename to sublime/syntaxes/extra/Reason.sublime-syntax diff --git a/sublime/syntaxes/Stylus.sublime-syntax b/sublime/syntaxes/extra/Stylus.sublime-syntax similarity index 100% rename from sublime/syntaxes/Stylus.sublime-syntax rename to sublime/syntaxes/extra/Stylus.sublime-syntax diff --git a/sublime/syntaxes/extra/Sublime-CMakeLists b/sublime/syntaxes/extra/Sublime-CMakeLists new file mode 160000 index 00000000..21e96989 --- /dev/null +++ b/sublime/syntaxes/extra/Sublime-CMakeLists @@ -0,0 +1 @@ +Subproject commit 21e96989d604d64f12d518f4f17fc71fa3cdc505 diff --git a/sublime/syntaxes/Sublime-GenericConfig b/sublime/syntaxes/extra/Sublime-GenericConfig similarity index 100% rename from sublime/syntaxes/Sublime-GenericConfig rename to sublime/syntaxes/extra/Sublime-GenericConfig diff --git a/sublime/syntaxes/SublimeElmLanguageSupport b/sublime/syntaxes/extra/SublimeElmLanguageSupport similarity index 100% rename from sublime/syntaxes/SublimeElmLanguageSupport rename to sublime/syntaxes/extra/SublimeElmLanguageSupport diff --git a/sublime/syntaxes/SublimeFortran b/sublime/syntaxes/extra/SublimeFortran similarity index 100% rename from sublime/syntaxes/SublimeFortran rename to sublime/syntaxes/extra/SublimeFortran diff --git a/sublime/syntaxes/extra/SublimeSass b/sublime/syntaxes/extra/SublimeSass new file mode 160000 index 00000000..48683220 --- /dev/null +++ b/sublime/syntaxes/extra/SublimeSass @@ -0,0 +1 @@ +Subproject commit 4868322030c3644d6b8cfff68c85849789d9bdb2 diff --git a/sublime/syntaxes/SublimeTextLinkerSyntax b/sublime/syntaxes/extra/SublimeTextLinkerSyntax similarity index 100% rename from sublime/syntaxes/SublimeTextLinkerSyntax rename to sublime/syntaxes/extra/SublimeTextLinkerSyntax diff --git a/sublime/syntaxes/Swift.sublime-syntax b/sublime/syntaxes/extra/Swift.sublime-syntax similarity index 100% rename from sublime/syntaxes/Swift.sublime-syntax rename to sublime/syntaxes/extra/Swift.sublime-syntax diff --git a/sublime/syntaxes/TypeScript.sublime-syntax b/sublime/syntaxes/extra/TypeScript.sublime-syntax similarity index 94% rename from sublime/syntaxes/TypeScript.sublime-syntax rename to sublime/syntaxes/extra/TypeScript.sublime-syntax index b491d3ba..25a82502 100644 --- a/sublime/syntaxes/TypeScript.sublime-syntax +++ b/sublime/syntaxes/extra/TypeScript.sublime-syntax @@ -9,10 +9,7 @@ contexts: main: - include: directives - include: statements - - match: \A(#!).*(?=$) - scope: comment.line.shebang.ts - captures: - 1: punctuation.definition.comment.ts + - include: shebang comment: - match: /\*\*(?!/) captures: @@ -120,7 +117,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -815,7 +812,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -856,7 +853,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -918,7 +915,7 @@ contexts: captures: 1: keyword.control.as.ts push: - - match: '(?=$|^|[;,:})\]]|\|\||\&\&|((?]|\|\||\&\&|\!\=\=|$|((?=|<>|<|> scope: keyword.operator.relational.ts - - match: '(\!)\s*(/)(?![/*])' + - match: '(?<=[_$[:alnum:]])(\!)\s*(/)(?![/*])' captures: 1: keyword.operator.logical.ts 2: keyword.operator.arithmetic.ts @@ -1038,7 +1035,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -1079,7 +1076,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -1125,25 +1122,42 @@ contexts: - match: \* scope: keyword.generator.asterisk.ts function-call: - - match: '(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + - match: '(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\())' push: - - match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + - match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\())' pop: true - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))' push: - meta_scope: meta.function-call.ts - - match: '(?=\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + - match: '(?=\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\())' pop: true - - include: support-function-call-identifiers - - match: '(\#?[_$[:alpha:]][_$[:alnum:]]*)' - scope: entity.name.function.ts + - include: function-call-target - include: comment - - match: \?\. - scope: meta.function-call.ts punctuation.accessor.optional.ts - - match: \! - scope: meta.function-call.ts keyword.operator.definiteassignment.ts + - include: function-call-optionals - include: type-arguments - include: paren-expression + - match: '(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))(<\s*[\{\[\(]\s*$))' + push: + - match: '(?<=\>)(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))(<\s*[\{\[\(]\s*$))' + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))' + push: + - meta_scope: meta.function-call.ts + - match: '(?=(<\s*[\{\[\(]\s*$))' + pop: true + - include: function-call-target + - include: comment + - include: function-call-optionals + - include: type-arguments + function-call-optionals: + - match: \?\. + scope: meta.function-call.ts punctuation.accessor.optional.ts + - match: \! + scope: meta.function-call.ts keyword.operator.definiteassignment.ts + function-call-target: + - include: support-function-call-identifiers + - match: '(\#?[_$[:alpha:]][_$[:alnum:]]*)' + scope: entity.name.function.ts function-declaration: - match: '(? on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -1431,7 +1445,7 @@ contexts: captures: 1: keyword.operator.expression.instanceof.ts push: - - match: '(?<=\))|(?=[;),}\]:?]|\|\||\&\&|$|((?]|\|\||\&\&|\!\=\=|$|(([\&\~\^\|]\s*)?[_$[:alpha:]][_$[:alnum:]]*\s+instanceof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?]|\|\||\&\&|\!\=\=|$|((? on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -1900,7 +1914,7 @@ contexts: 1: keyword.control.as.ts push: - meta_scope: meta.object.member.ts - - match: '(?=$|^|[,}]|\|\||\&\&|((?]|\|\||\&\&|\!\=\=|$|^|((? on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -2051,7 +2065,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -2313,6 +2327,11 @@ contexts: - include: type-object - include: type-predicate-operator - include: type + shebang: + - match: \A(#!).*(?=$) + scope: comment.line.shebang.ts + captures: + 1: punctuation.definition.comment.ts single-line-comment-consuming-line-ending: - match: '(^[ \t]+)?((//)(?:\s*((@)internal)(?=\s|$))?)' captures: @@ -2684,20 +2703,20 @@ contexts: 0: case-clause.expr.ts punctuation.definition.section.case-statement.ts - include: statements template: - - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' push: - meta_scope: string.template.ts - match: (?=`) pop: true - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))' push: - - match: '(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + - match: '(?=(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' pop: true - include: support-function-call-identifiers - match: "([_$[:alpha:]][_$[:alnum:]]*)" scope: entity.name.function.tagged-template.ts - include: type-arguments - - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)`)' + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)`)' captures: 1: entity.name.function.tagged-template.ts push: @@ -2974,6 +2993,8 @@ contexts: scope: keyword.operator.ternary.ts - match: '(? on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -3200,7 +3228,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -3246,7 +3274,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) @@ -3287,7 +3315,7 @@ contexts: # arrow function possible to detect only with => on same line ( (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters - \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) diff --git a/sublime/syntaxes/TypeScriptReact.sublime-syntax b/sublime/syntaxes/extra/TypeScriptReact.sublime-syntax similarity index 62% rename from sublime/syntaxes/TypeScriptReact.sublime-syntax rename to sublime/syntaxes/extra/TypeScriptReact.sublime-syntax index 05ab04e6..ff59108b 100644 --- a/sublime/syntaxes/TypeScriptReact.sublime-syntax +++ b/sublime/syntaxes/extra/TypeScriptReact.sublime-syntax @@ -9,10 +9,7 @@ contexts: main: - include: directives - include: statements - - match: \A(#!).*(?=$) - scope: comment.line.shebang.ts - captures: - 1: punctuation.definition.comment.ts + - include: shebang comment: - match: /\*\*(?!/) captures: @@ -44,10 +41,10 @@ contexts: 5: punctuation.decorator.internaldeclaration.tsx push: - meta_content_scope: comment.line.double-slash.tsx - - match: (?=^) + - match: (?=$) pop: true access-modifier: - - match: '(?]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&&|\|\||\*)\s*(\{)' @@ -109,8 +106,8 @@ contexts: (?= # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -121,9 +118,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) ) @@ -138,13 +135,15 @@ contexts: - include: type-parameters - include: function-parameters - include: arrow-return-type + - include: possibly-arrow-return-type - match: "=>" captures: 0: storage.type.function.arrow.tsx push: - meta_scope: meta.arrow.tsx - - match: '(?<=\}|\S)(?)|((?!\{)(?=\S))' + - match: '((?<=\}|\S)(?)|((?!\{)(?=\S)))(?!\/[\/\*])' pop: true + - include: single-line-comment-consuming-line-ending - include: decl-block - include: expression arrow-return-type: @@ -170,6 +169,8 @@ contexts: binding-element: - include: comment - include: string + - include: numeric-literal + - include: regex - include: object-binding-pattern - include: array-binding-pattern - include: destructuring-variable-rest @@ -177,6 +178,8 @@ contexts: binding-element-const: - include: comment - include: string + - include: numeric-literal + - include: regex - include: object-binding-pattern-const - include: array-binding-pattern-const - include: destructuring-variable-rest-const @@ -200,11 +203,12 @@ contexts: cast: - include: jsx class-declaration: - - match: '(?\s*$)' + - match: '^(///)\s*(?=<(reference|amd-dependency|amd-module)(\s+(path|types|no-default-lib|lib|name)\s*=\s*((\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)))+\s*/>\s*$)' captures: 1: punctuation.definition.comment.tsx push: - meta_scope: comment.line.triple-slash.directive.tsx - - match: (?=^) + - match: (?=$) pop: true - match: (<)(reference|amd-dependency|amd-module) captures: @@ -668,13 +681,18 @@ contexts: captures: 1: punctuation.definition.block.tag.jsdoc - include: inline-tags + - match: '((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\s+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc enum-declaration: - - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: storage.modifier.tsx + 2: keyword.operator.rest.tsx + 3: entity.name.function.tsx variable.language.this.tsx + 4: entity.name.function.tsx + 5: keyword.operator.optional.tsx + - match: '(?x)(?:(?]|\|\||\&\&|\!\=\=|$|((?=|<>|<|> scope: keyword.operator.relational.tsx - - match: \!|&&|\|\| + - match: '(?<=[_$[:alnum:]])(\!)\s*(/)(?![/*])' + captures: + 1: keyword.operator.logical.tsx + 2: keyword.operator.arithmetic.tsx + - match: \!|&&|\|\||\?\? scope: keyword.operator.logical.tsx - match: \&|~|\^|\| scope: keyword.operator.bitwise.tsx @@ -800,6 +927,13 @@ contexts: scope: keyword.operator.increment.tsx - match: '%|\*|/|-|\+' scope: keyword.operator.arithmetic.tsx + - match: '(?<=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(/)(?![/*]))' + push: + - match: '(/)(?!\*([^\*]|(\*[^\/]))*\*\/)' + captures: + 1: keyword.operator.arithmetic.tsx + pop: true + - include: comment - match: '(?<=[_$[:alnum:])\]])\s*(/)(?![/*])' captures: 1: keyword.operator.arithmetic.tsx @@ -810,7 +944,6 @@ contexts: - include: jsx - include: string - include: regex - - include: template - include: comment - include: function-expression - include: class-expression @@ -828,143 +961,123 @@ contexts: - include: paren-expression field-declaration: - match: |- - (?x)(?) - )) | - ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | - # sure shot arrow functions even if => is on new line - ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* - ( - ([)]\s*:) | # (): - ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: - ) - ) | - ( - [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends - ) | - # arrow function possible to detect only with => on same line - ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type - \s*=> # arrow operator - ) - )) - )) | - # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => - (:\s*( - (<) | - ([(]\s*( - ([)]) | - (\.\.\.) | - ([_$[:alnum:]]+\s*( - ([:,?=])| - ([)]\s*=>) - )) - )) - )) | - (:\s*((<\s*$)|([\(]\s*([\{\[]\s*)?$))) | - (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( - ((async\s+)?( - (function\s*[(<*]) | - (function\s+) | - ([_$[:alpha:]][_$[:alnum:]]*\s*=>) - )) | - ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | - # sure shot arrow functions even if => is on new line - ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* - ( - ([)]\s*:) | # (): - ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: - ) - ) | - ( - [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends - ) | - # arrow function possible to detect only with => on same line - ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type - \s*=> # arrow operator - ) - )) - ))) - captures: - 1: meta.definition.property.tsx entity.name.function.tsx - 2: keyword.operator.optional.tsx - - match: "[_$[:alpha:]][_$[:alnum:]]*" - scope: meta.definition.property.tsx variable.object.property.tsx - - match: \? - scope: keyword.operator.optional.tsx + (?x)(\#?[_$[:alpha:]][_$[:alnum:]]*)(?:(\?)|(\!))?(?=\s*\s* + # function assignment | + (=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.property.tsx entity.name.function.tsx + 2: keyword.operator.optional.tsx + 3: keyword.operator.definiteassignment.tsx + - match: '\#?[_$[:alpha:]][_$[:alnum:]]*' + scope: meta.definition.property.tsx variable.object.property.tsx + - match: \? + scope: keyword.operator.optional.tsx + - match: \! + scope: keyword.operator.definiteassignment.tsx for-loop: - match: '(?\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>\s*)?\()' + - match: '(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\())' push: - - match: '(?<=\))(?!(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)\s*(\?\.\s*)?(<\s*(((keyof|infer)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>\s*)?\()' + - match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\())' pop: true - - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))' + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))' push: - meta_scope: meta.function-call.tsx - - match: '(?=\s*(\?\.\s*)?(<\s*(((keyof|infer)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>\s*)?\()' + - match: '(?=\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\())' pop: true - - include: literal - - include: support-objects - - include: object-identifiers - - include: punctuation-accessor - - match: '(?:(?)(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))(<\s*[\{\[\(]\s*$))' + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))' + push: + - meta_scope: meta.function-call.tsx + - match: '(?=(<\s*[\{\[\(]\s*$))' + pop: true + - include: function-call-target + - include: comment + - include: function-call-optionals + - include: type-arguments + function-call-optionals: + - match: \?\. + scope: meta.function-call.tsx punctuation.accessor.optional.tsx + - match: \! + scope: meta.function-call.tsx keyword.operator.definiteassignment.tsx + function-call-target: + - include: support-function-call-identifiers + - match: '(\#?[_$[:alpha:]][_$[:alnum:]]*)' + scope: entity.name.function.tsx function-declaration: - - match: '(?) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -1092,9 +1222,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -1103,12 +1233,12 @@ contexts: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx 3: entity.name.function.tsx - - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' + - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(\#?[[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx 3: variable.other.constant.property.tsx - - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*([_$[:alpha:]][_$[:alnum:]]*)' + - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(\#?[_$[:alpha:]][_$[:alnum:]]*)' captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx @@ -1117,15 +1247,46 @@ contexts: scope: variable.other.constant.tsx - match: "[_$[:alpha:]][_$[:alnum:]]*" scope: variable.other.readwrite.tsx + if-statement: + - match: '(?]|\|\||\&\&|\!\=\=|$|(([\&\~\^\|]\s*)?[_$[:alpha:]][_$[:alnum:]]*\s+instanceof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?))' + - match: '(?=(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' push: - meta_scope: meta.tag.tsx - - match: '(/>)|(?:())' + - match: '(/>)|(?:())' captures: 1: punctuation.definition.tag.end.tsx 2: punctuation.definition.tag.begin.tsx @@ -1365,7 +1532,7 @@ contexts: 6: support.class.component.tsx 7: punctuation.definition.tag.end.tsx pop: true - - match: '(<)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?)' + - match: '(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?)' captures: 1: punctuation.definition.tag.begin.tsx 2: entity.name.tag.namespace.tsx @@ -1393,8 +1560,8 @@ contexts: - match: |- (?x) \s* - (?:([_$[:alpha:]][-$[:alnum:].]*)(:))? - ([_$[:alpha:]][-$[:alnum:]]*) + (?:([_$[:alpha:]][-_$[:alnum:].]*)(:))? + ([_$[:alpha:]][-_$[:alnum:]]*) (?=\s|=|/?>|/\*|//) captures: 1: entity.other.attribute-name.namespace.tsx @@ -1419,15 +1586,15 @@ contexts: jsx-tag-in-expression: - match: |- (?x) - (?:*]|&&|\|\||\?|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s* + (?:*]|&&|\|\||\?|\*\/|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s* (?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow - (?=(<)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?)) + (?=(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?)) push: - - match: '(?!(<)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?))' + - match: '(?!(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' pop: true - include: jsx-tag jsx-tag-without-attributes: - - match: '(<)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?)' + - match: '(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?)' captures: 1: punctuation.definition.tag.begin.tsx 2: entity.name.tag.namespace.tsx @@ -1438,7 +1605,7 @@ contexts: push: - meta_scope: meta.tag.without-attributes.tsx - meta_content_scope: meta.jsx.children.tsx - - match: '()' + - match: '()' captures: 1: punctuation.definition.tag.begin.tsx 2: entity.name.tag.namespace.tsx @@ -1449,9 +1616,9 @@ contexts: pop: true - include: jsx-children jsx-tag-without-attributes-in-expression: - - match: '(?:*]|&&|\|\||\?|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s*(?=(<)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?))' + - match: '(?:*]|&&|\|\||\?|\*\/|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s*(?=(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' push: - - match: '(?!(<)\s*(?:([_$[:alpha:]][-$[:alnum:].]*)(?))' + - match: '(?!(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' pop: true - include: jsx-tag-without-attributes label: @@ -1489,7 +1656,7 @@ contexts: pop: true - include: method-declaration-name - include: function-body - - match: '(?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])' captures: 1: storage.modifier.tsx 2: storage.modifier.tsx @@ -1503,16 +1670,16 @@ contexts: - include: method-declaration-name - include: function-body - match: |- - (?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) captures: 1: storage.modifier.tsx 2: storage.modifier.tsx @@ -1527,16 +1694,16 @@ contexts: - include: function-body method-declaration-name: - match: |- - (?x)(?=((\b(?]|\|\||\&\&|\!\=\=|$|((?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) captures: 1: storage.modifier.async.tsx 2: storage.type.property.tsx @@ -1751,16 +1933,16 @@ contexts: - include: method-declaration-name - include: function-body - match: |- - (?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) captures: 1: storage.modifier.async.tsx 2: storage.type.property.tsx @@ -1777,37 +1959,56 @@ contexts: - meta_scope: meta.object.member.tsx meta.object-literal.key.tsx - match: '(?=:)|((?<=[\]])(?=\s*[\(\<]))' pop: true + - include: comment - include: array-literal - - match: '(?=[\''\"])' + - match: '(?=[\''\"\`])' push: - meta_scope: meta.object.member.tsx meta.object-literal.key.tsx - - match: '(?=:)|((?<=[\''\"])(?=\s*[\(\<]))' + - match: '(?=:)|((?<=[\''\"\`])(?=((\s*[\(\<,}])|(\s+(as)\s+))))' pop: true + - include: comment - include: string - - match: '(?<=[\]\''\"])(?=\s*[\(\<])' + - match: |- + (?x)(?=(\b(?) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -1818,9 +2019,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -1829,7 +2030,7 @@ contexts: captures: 0: meta.object-literal.key.tsx 1: entity.name.function.tsx - - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=:)' + - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*:)' scope: meta.object.member.tsx captures: 0: meta.object-literal.key.tsx @@ -1841,14 +2042,27 @@ contexts: - match: '(?=,|\})' pop: true - include: expression - - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)' + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$|\/\/|\/\*)' scope: meta.object.member.tsx captures: 1: variable.other.readwrite.tsx + - match: '(?]|\|\||\&\&|\!\=\=|$|^|((?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)\(\s*([\{\[]\s*)?$)' + - match: '(?<=:)\s*(async)?(?=\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' captures: 1: storage.modifier.async.tsx push: @@ -1874,7 +2088,7 @@ contexts: 0: meta.brace.round.tsx pop: true - include: expression-inside-possibly-arrow-parens - - match: '(?<=:)\s*(async)?\s*(\()(?=\s*([\{\[]\s*)?$)' + - match: '(?<=:)\s*(async)?\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' captures: 1: storage.modifier.async.tsx 2: meta.brace.round.tsx @@ -1884,6 +2098,23 @@ contexts: 0: meta.brace.round.tsx pop: true - include: expression-inside-possibly-arrow-parens + - match: (?<=:)\s*(async)?\s*(?=\<\s*$) + captures: + 1: storage.modifier.async.tsx + push: + - match: (?<=\>) + pop: true + - include: type-parameters + - match: '(?<=\>)\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: meta.brace.round.tsx + push: + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - include: expression-inside-possibly-arrow-parens + - include: possibly-arrow-return-type - include: expression - include: punctuation-comma parameter-array-binding-pattern: @@ -1901,6 +2132,8 @@ contexts: parameter-binding-element: - include: comment - include: string + - include: numeric-literal + - include: regex - include: parameter-object-binding-pattern - include: parameter-array-binding-pattern - include: destructuring-parameter-rest @@ -1919,11 +2152,11 @@ contexts: ([_$[:alpha:]][_$[:alnum:]]*\s*=>) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -1934,9 +2167,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -1953,7 +2186,8 @@ contexts: )) )) )) | - (:\s*((<\s*$)|([\(]\s*([\{\[]\s*)?$))) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( ((async\s+)?( (function\s*[(<*]) | @@ -1961,11 +2195,11 @@ contexts: ([_$[:alpha:]][_$[:alnum:]]*\s*=>) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -1976,9 +2210,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -1999,16 +2233,16 @@ contexts: parameter-object-binding-element: - include: comment - match: |- - (?x)(?=((\b(?])" + pop: true + - include: type paren-expression: - match: \( captures: @@ -2040,14 +2283,14 @@ contexts: pop: true - include: expression paren-expression-possibly-arrow: - - match: '(?<=[(=,])\s*(async)?(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*))?\(\s*[\{\[]\s*$)' + - match: '(?<=[(=,])\s*(async)?(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' captures: 1: storage.modifier.async.tsx push: - match: (?<=\)) pop: true - include: paren-expression-possibly-arrow-with-typeparameters - - match: '(?<=[(=,]|=>)\s*(async)?(?=\s*((((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*))?\()|(<))\s*$)' + - match: '(?<=[(=,]|=>|^return|[^\._$[:alnum:]]return)\s*(async)?(?=\s*((((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\()|(<))\s*$)' captures: 1: storage.modifier.async.tsx push: @@ -2067,7 +2310,7 @@ contexts: pop: true - include: expression-inside-possibly-arrow-parens possibly-arrow-return-type: - - match: '(?<=\))\s*(:)(?=\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+\s*=>)' + - match: '(?<=\)|^)\s*(:)(?=\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*=>)' captures: 1: meta.arrow.tsx meta.return.type.arrow.tsx keyword.operator.type.annotation.tsx push: @@ -2114,7 +2357,7 @@ contexts: pop: true - include: string-character-escape regex: - - match: '(?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/[gimsuy]*(?!\s*[a-zA-Z0-9_$]))' + - match: '(?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))' captures: 1: punctuation.definition.string.begin.tsx push: @@ -2125,7 +2368,7 @@ contexts: 2: keyword.other.tsx pop: true - include: regexp - - match: '(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\()) | - (EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY))\b(?!\$) + (?:(EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY)\b(?!\$))) captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx @@ -2415,7 +2682,7 @@ contexts: |siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary |systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead |title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile - |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?\() + |vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\() captures: 1: punctuation.accessor.tsx 2: punctuation.accessor.optional.tsx @@ -2539,6 +2806,7 @@ contexts: captures: 0: punctuation.definition.block.tsx pop: true + - include: comment - match: '(?\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[=]|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?!=)\>)*(?!=)>\s*)`)' + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + push: + - meta_scope: string.template.tsx + - match: (?=`) + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))' + push: + - match: '(?=(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + pop: true + - include: support-function-call-identifiers + - match: "([_$[:alpha:]][_$[:alnum:]]*)" + scope: entity.name.function.tagged-template.tsx + - include: type-arguments + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)`)' captures: 1: entity.name.function.tagged-template.tsx push: @@ -2614,7 +2895,7 @@ contexts: pop: true - include: expression ternary-expression: - - match: '(?!\?\.\s*[^[:digit:]])(\?)' + - match: '(?!\?\.\s*[^[:digit:]])(\?)(?!\?)' captures: 1: keyword.operator.ternary.tsx push: @@ -2640,16 +2921,20 @@ contexts: - include: type-fn-type-parameters - include: type-paren-or-function-parameters - include: type-function-return-type + - match: '(?) + pop: true + - include: comment + - include: type-parameters - match: '(?) + captures: + 1: meta.type.parameters.tsx punctuation.definition.typeparameters.end.tsx + pop: true + - include: type-arguments-body + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(<)' + captures: + 1: entity.name.type.tsx + 2: meta.type.parameters.tsx punctuation.definition.typeparameters.begin.tsx + push: + - meta_content_scope: meta.type.parameters.tsx + - match: (>) + captures: + 1: meta.type.parameters.tsx punctuation.definition.typeparameters.end.tsx + pop: true + - include: type-arguments-body - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))' captures: 1: entity.name.type.module.tsx @@ -2802,18 +3120,16 @@ contexts: - include: type type-operators: - include: typeof-operator - - match: '(?:([&|])|(=(?!>)))(?=\s*\{)' + - match: '([&|])(?=\s*\{)' captures: - 1: keyword.operator.type.tsx - 2: keyword.operator.assignment.tsx + 0: keyword.operator.type.tsx push: - match: '(?<=\})' pop: true - include: type-object - - match: "([&|])|(=(?!>))" + - match: "[&|]" captures: - 1: keyword.operator.type.tsx - 2: keyword.operator.assignment.tsx + 0: keyword.operator.type.tsx push: - match: (?=\S) pop: true @@ -2823,6 +3139,8 @@ contexts: scope: keyword.operator.ternary.tsx - match: '(?) + scope: keyword.operator.assignment.tsx type-paren-or-function-parameters: - match: \( captures: @@ -2850,7 +3170,6 @@ contexts: captures: 0: meta.brace.round.tsx pop: true - - include: destructuring-parameter - match: |- (?x)(?:(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))))) captures: 1: storage.modifier.tsx 2: keyword.operator.rest.tsx @@ -2882,10 +3202,23 @@ contexts: scope: punctuation.separator.parameter.tsx - include: type type-predicate-operator: + - match: '(?) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -2978,9 +3334,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -2997,7 +3353,8 @@ contexts: )) )) )) | - (:\s*((<\s*$)|([\(]\s*([\{\[]\s*)?$))) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( ((async\s+)?( (function\s*[(<*]) | @@ -3005,11 +3362,11 @@ contexts: ([_$[:alpha:]][_$[:alnum:]]*\s*=>) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -3020,9 +3377,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -3031,7 +3388,7 @@ contexts: 1: meta.definition.variable.tsx variable.other.constant.tsx entity.name.function.tsx push: - meta_scope: meta.var-single-variable.expr.tsx - - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' + - match: '(?=$|^|[;,=}]|((?) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -3068,9 +3425,9 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) @@ -3087,7 +3444,8 @@ contexts: )) )) )) | - (:\s*((<\s*$)|([\(]\s*([\{\[]\s*)?$))) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( ((async\s+)?( (function\s*[(<*]) | @@ -3095,11 +3453,11 @@ contexts: ([_$[:alpha:]][_$[:alnum:]]*\s*=>) )) | ((async\s*)?( - ((<\s*$)|([\(]\s*([\{\[]\s*)?$)) | + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | # sure shot arrow functions even if => is on new line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? - [(]\s* + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* ( ([)]\s*:) | # (): ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: @@ -3110,34 +3468,37 @@ contexts: ) | # arrow function possible to detect only with => on same line ( - (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters - \(\s*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters - (\s*:\s*([^<>\(\)]|\<[^<>]+\>|\([^\(\)]+\))+)? # return type + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type \s*=> # arrow operator ) )) ))) captures: 1: meta.definition.variable.tsx entity.name.function.tsx + 2: keyword.operator.definiteassignment.tsx push: - meta_scope: meta.var-single-variable.expr.tsx - - match: '(?=$|^|[;,=}]|(\s+(of|in)\s+))' + - match: '(?=$|^|[;,=}]|((?\s*$) captures: 1: keyword.operator.assignment.tsx push: - - match: '(?=$|^|[,);}\]])' + - match: '(?=$|^|[,);}\]]|((?