Migrate to shiki

Prism seems unmaintained

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2024-08-14 22:13:33 +05:30
parent f8d794d2e8
commit 328a3f9f8d
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
3 changed files with 32 additions and 19 deletions

24
Cargo.lock generated
View file

@ -153,9 +153,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-web" name = "actix-web"
version = "4.8.0" version = "4.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1988c02af8d2b718c05bc4aeb6a66395b7cdf32858c2c71131e5637a8c05a9ff" checksum = "9180d76e5cc7ccbc4d60a506f2c727730b154010262df5b910eb17dbe4b8cb38"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-http", "actix-http",
@ -175,6 +175,7 @@ dependencies = [
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
"impl-more",
"itoa", "itoa",
"language-tags", "language-tags",
"log", "log",
@ -845,6 +846,12 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "impl-more"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d"
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.9.0" version = "2.9.0"
@ -1481,18 +1488,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.204" version = "1.0.207"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.204" version = "1.0.207"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1501,11 +1508,12 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.120" version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr",
"ryu", "ryu",
"serde", "serde",
] ]

View file

@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
actix-web = { version = "4.8.0", default-features = false, features = ["macros", "compress-brotli", "compress-gzip", "cookies"]} actix-web = { version = "4.9.0", default-features = false, features = ["macros", "compress-brotli", "compress-gzip", "cookies"]}
actix-files = "0.6.6" actix-files = "0.6.6"
tera = "1.20.0" tera = "1.20.0"
serde = { version = "1.0.204", features = ["derive"] } serde = { version = "1.0.207", features = ["derive"] }
reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls", "gzip"] } reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls", "gzip"] }
serde_json = "1.0.120" serde_json = "1.0.124"
base64 = "0.22.1" base64 = "0.22.1"
mime = "0.3.17" mime = "0.3.17"

View file

@ -21,17 +21,22 @@
</script> </script>
{% else %} {% else %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script> <script type="module">
document.addEventListener("DOMContentLoaded", (event) => {
import { codeToHtml } from 'https://esm.sh/shiki@1.0.0'
document.addEventListener("DOMContentLoaded", async (event) => {
const elem = document.getElementById("pastecontent"); const elem = document.getElementById("pastecontent");
hljs.highlightElement(elem); const result = hljs.highlightAuto(elem.textContent);
Prism.highlightElement(elem); const detectedLang = result.language || 'txt';
// Set the highlighted HTML
elem.innerHTML = await codeToHtml(elem.textContent, {
lang: detectedLang,
theme: 'andromeeda'
});
}); });
</script> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Fira Code' rel='stylesheet'>
<pre class="w-10/12 text-gray-100 border border-solid border-emerald-200 rounded bg-zinc-800 p-2"><code id="pastecontent">{{paste_content}}</code></pre> <pre class="w-10/12 text-gray-100 border border-solid border-emerald-200 rounded bg-zinc-800 p-2"><code id="pastecontent">{{paste_content}}</code></pre>
{% endif %} {% endif %}
{% endblock content %} {% endblock content %}