JohnSundell/Splash là dự án tập trung di động trên GitHub với 1.9k sao, viết chủ yếu bằng Swift. A fast, lightweight and flexible Swift syntax highlighter for blogs, tools and fun!
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Welcome to Splash - a fast, lightweight and flexible Swift syntax highlighter. It can be used to generate code sample HTML for a blog post, to turn a string of Swift code into a fully syntax highlighted image, or to build custom developer tools.
It's used to highlight all articles on swiftbysundell.com.
Usage
Splash can be used either as a library in your own Swift Package Manager-powered tool or script, or by using one of the four built-in command line tools that act as frontends for the Splash library.
🌍 On the web
If you're using Publish, then there's an official plugin that makes it easy to integrate Splash into your website:
👉 SplashPublishPlugin
If you're using Jekyll, there's also a custom {% splash %} tag available for the Liquid templating language.
👉 splashtag
🖥 On the command line
The easiest way to get started building things with Splash is to use one of the four built-in command line tools that each enable you to use Splash in different ways.
SplashHTMLGen
SplashHTMLGen uses Splash's HTML output format to generate an HTML string from Swift code. You simply pass it the code you want to highlight as an argument and HTML is returned as standard output.
To be as flexible as possible, Splash doesn't hardcode any colors or other CSS attributes in the HTML it generates. Instead it simply assigns a CSS class to each token. For an example of a CSS file that can be used to style Splash-generated HTML, see Examples/sundellsColors.css.
When rendering your outputted html, make sure to wrap your output code in the <pre> and <code> tags and properly link to your .css file. Like this:
For more information about HTML generation with Splash and how to customize it, see HTMLOutputFormat here.
SplashMarkdown
SplashMarkdown builds on top of SplashHTMLGen to enable easy Splash decoration of any Markdown file. Pass it a path to a Markdown file, and it will iterate through all code blocks within that file and convert them into Splash-highlighted HTML.
Just like the HTML generated by SplashHTMLGen itself, a CSS file should also be added to any page serving the processed Markdown, since Splash only adds CSS classes to tokens — rather than hardcoding styles inline. See the above SplashHTMLGen documentation for more information.
Here’s an example call to decorate a Markdown file at the path ~/Documents/Article.md:
$ SplashMarkdown ~/Documents/Article.md
The decorated Markdown will be returned as standard output.
Highlighting can be skipped for any code block by adding no-highlight next to the block’s opening row of backticks — like this: “```no-highlight”.
SplashImageGen
SplashImageGen uses Splash to generate an NSAttributedString from Swift code, then draws that attributed string into a graphics context to turn it into an image, which is then written to disk.
The following image will be generated (and written to disk as MyImage.png):
SplashImageGen is currently only available on macOS.
SplashTokenizer
The final built-in command line tool, SplashTokenizer, is mostly useful as a debugging tool when working on Splash - but can also be interesting to use in order to see how Splash breaks down code into tokens. Given a string of Swift code, it simply outputs all of its components (excluding whitespaces).
Keyword token: func
Plain text: hello(world:
Type token: String
Plain text: )
Plain text: ->
Type token: Int
📦 As a package
To include Splash in your own script or Swift package, add it as a dependency and use the SyntaxHighlighter class combined with your output format of choice to highlight a string of code:
import Splash
let highlighter = SyntaxHighlighter(format: HTMLOutputFormat())
let html = highlighter.highlight("func hello() -> String")
Splash ships with two built-in output formats - HTML and NSAttributedString, but you can also easily add your own by implementing the OutputFormat protocol.
Installation
Splash is distributed as a Swift package, making it easy to install for use in scripts, developer tools, server-side applications, or to use its built-in command line tools.
Splash supports both macOS and Linux.
Before you begin, make sure that you have a Swift 5.2-compatible toolchain installed (for example Xcode 11.5 or later if you're on a Mac).
📦 As a package
To install Splash for use in a Swift Package Manager-powered tool or server-side application, add Splash as a dependency to your Package.swift file. For more information, please see the Swift Package Manager documentation.
Splash is developed completely in the open, and your contributions are more than welcome. It's still a very new project, so I'm sure there are bugs to be found and improvements to be made - and hopefully we can work on those together as a community.
This project does not come with GitHub Issues-based support, and users are instead encouraged to become active participants in its continued development — by fixing any bugs that they encounter, or by improving the documentation wherever it's found to be lacking.
To read more about suggested workflows when contributing to Splash, how to report bugs and feature requests, as well as technical details and an architectural overview - check out the Contributing Guide.
Hope you enjoy using Splash!
I had a lot of fun building Splash, and I'm looking forward to continue working on it in the open together with you! I hope you'll like it and that you'll find it useful. Let me know what you think on Twitter 😊
JohnSundell/Splash thuộc nhóm Mobile trên TopGit, cùng 4 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về JohnSundell/Splash ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/JohnSundell/Splash là nguồn chính thức.
JohnSundell/Splash có phải mã nguồn mở không?
Có — JohnSundell/Splash phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/JohnSundell/Splash.
JohnSundell/Splash là gì?
JohnSundell/Splash (JohnSundell/Splash) là dự án Swift trên GitHub. Theo mô tả gốc: A fast, lightweight and flexible Swift syntax highlighter for blogs, tools and fun!
JohnSundell/Splash so với các dự án Mobile khác thế nào?
JohnSundell/Splash được TopGit xếp vào nhóm Mobile, với 1.9k sao GitHub và viết bằng Swift. Xem trang chủ đề Mobile trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Vì sao JohnSundell/Splash được xếp vào nhóm Mobile?
TopGit xếp JohnSundell/Splash vào nhóm Mobile dựa trên GitHub topics và mô tả của repo (gắn thẻ: "command-line-tool", "swift", "swift-package"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc Splash có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về Splash.