How to enable syntax highlighting for Swift on Squarespace

Published by

on

Let’s enabling syntax highlighting for Swift

The Squarespace supports syntax highlighting for HTML, CSS, and Javascript.

But It does not support other programming languages.

To enable it, We can choose the syntax highlighting plugins.

I recommend PrismJS

Download PrismJS css and javascript

prismjs_compressionLevel.png

Select PrismJS option before downloading it.

  • Compression level to Minified version

  • Language for Swift

  • Plugins (e.g., line numbers)

prismjs_download.png

Download the JS and CSS. That’s it.

Copy and Paste it into the Squarespace

EditingBlog.png

Go to the setting Pages > Select your blog page (e.g., Posts)

CodeInjection.png

Go to Advanced tap and Copy and Paste the CSS and Javascript code into the Post Blog Item Code injection

<style>
<!-- Paste Your PrismJS CSS -->
</style>
<script>
/*
Paste your PrismJS Javascript
*/
</script>

Now We can syntax highlighting for Swift using Markdown

markdown.png.jpeg

let greeting = "Welcome to Shawn Baek's blog!"
print(greeting)