{"id":13872295,"url":"https://github.com/nerdsupremacist/syntax-highlight-publish-plugin","last_synced_at":"2025-09-13T06:43:14.755Z","repository":{"id":63919085,"uuid":"329704582","full_name":"nerdsupremacist/syntax-highlight-publish-plugin","owner":"nerdsupremacist","description":"Plugin to add syntax highlighting (for multiple languages) to your Publish Site, with the least amount of effort.","archived":false,"fork":false,"pushed_at":"2021-02-07T22:11:29.000Z","size":41,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-09-16T17:49:22.100Z","etag":null,"topics":["plugin","publish","publish-plugin","splash","syntax","syntax-highlighting","textmate"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerdsupremacist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-14T18:43:24.000Z","updated_at":"2023-06-22T02:01:58.000Z","dependencies_parsed_at":"2023-01-14T14:00:24.336Z","dependency_job_id":null,"html_url":"https://github.com/nerdsupremacist/syntax-highlight-publish-plugin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdsupremacist%2Fsyntax-highlight-publish-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdsupremacist%2Fsyntax-highlight-publish-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdsupremacist%2Fsyntax-highlight-publish-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdsupremacist%2Fsyntax-highlight-publish-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerdsupremacist","download_url":"https://codeload.github.com/nerdsupremacist/syntax-highlight-publish-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860693,"owners_count":16556011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plugin","publish","publish-plugin","splash","syntax","syntax-highlighting","textmate"],"created_at":"2024-08-05T23:00:38.945Z","updated_at":"2024-10-11T13:33:10.252Z","avatar_url":"https://github.com/nerdsupremacist.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Syntax Highlight Publish Plugin\n\nPlugin to add syntax highlighting (for multiple languages) to your Publish Site, with the least amount of effort. \nIt currently supports defining Grammars with:\n- [Syntax](https://github.com/nerdsupremacist/Syntax): SwiftUI-like parser builder DSL\n- [TextMate](https://macromates.com/manual/en/language_grammars) Grammars\n- [Splash](https://github.com/JohnSundell/Splash) Grammars\n\n## Installation\n### Swift Package Manager\n\nYou can install SyntaxHighlightPublishPlugin via [Swift Package Manager](https://swift.org/package-manager/) by adding the following line to your `Package.swift`:\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    [...]\n    dependencies: [\n        .package(url: \"https://github.com/nerdsupremacist/syntax-highlight-publish-plugin.git\", from: \"0.1.0\")\n    ]\n)\n```\n\n## Usage\n\nYou have three options to add new Grammars to your site:\n- Use Syntax\n- Use TextMate\n- Use Splash\n\nYou are allowed to add as many grammars as you like. And the plugin will choose the correct grammar depending on the language in each code block:\n\n```swift\ntry MyPublishSite().publish(using: [\n    ...\n    // use plugin and include all the grammars that you want to use (note: we only ship this plugin with Swift)\n    .installPlugin(.syntaxHighlighting(.swift, .kotlin, .scala, .java, .json, .graphql)),\n])\n```\n\n\u003cimg src=\"https://github.com/nerdsupremacist/Syntax/raw/develop/logo.png\" width=\"300\" max-width=\"90%\" alt=\"Syntax\" /\u003e\n\n### Syntax\n\n[Syntax](https://github.com/nerdsupremacist/Syntax) is a SwiftUI-like parser builder DSL that you can use to define your custom Grammar structurally.\nFor example this is how you would write a Parser that can parse the output of FizzBuzz:\n\n```swift\nenum FizzBuzzValue {\n    case number(Int)\n    case fizz\n    case buzz\n    case fizzBuzz\n}\n\nstruct FizzBuzzParser: Parser {\n    var body: AnyParser\u003c[FizzBuzzValue]\u003e {\n        Repeat {\n            Either {\n                IntLiteral().map { FizzBuzzValue.number($0) }\n\n                Word(\"FizzBuzz\").map(to: FizzBuzzValue.fizzBuzz)\n                Word(\"Fizz\").map(to: FizzBuzzValue.fizz)\n                Word(\"Buzz\").map(to: FizzBuzzValue.buzz)\n            }\n        }\n    }\n}\n```\n\nAnd in order to add it to our site we use the Parser to create a `Grammar`:\n\n```swift\nimport SyntaxHighlightPublishPlugin\n\nextension Grammar {\n    // define Fizz Buzz Grammar\n    static let fizzBuzz = Grammar(name: \"FizzBuzz\") {\n        FizzBuzzParser()\n    }\n}\n\ntry MyPublishSite().publish(using: [\n    ...\n    // use plugin and include your Grammar\n    .installPlugin(.syntaxHighlighting(.fizzbuzz)),\n])\n```\n\n### TextMate\n\nMost programming languages have a TextMate definition out there so that you don't have to put in the work in coding it all down. \n\nYou can simply search for the VS Code plugin for your language of choice and in the repo you will most likely find a .tmLanguage file. \nThat's all you need to add support for that language on your site.\n\nLet's say for that you want to add support for Kotlin:\n\n```swift\nimport SyntaxHighlightPublishPlugin\n\nextension Grammar {\n    static let kotlin = try! Grammar(textMateFile: URL(fileURLWithPath: \"/path/to/Kotlin.tmLanguage\"))\n}\n\ntry MyPublishSite().publish(using: [\n    ...\n    .installPlugin(.syntaxHighlighting(.kotlin)),\n])\n```\n\n\u003cimg src=\"https://github.com/JohnSundell/Splash/raw/master/Images/Logo.png\" width=\"300\" max-width=\"90%\" alt=\"Syntax\" /\u003e\n\n### Splash\n\nIf you were already using [Splash](https://github.com/JohnSundell/Splash) on your site before and put in the work to add a custom Splash Grammar. No problem. We can use that too:\n\n```swift\nimport SyntaxHighlightPublishPlugin\n\nextension Grammar {\n    static let myLanguage = Grammar(name: \"MyLanguage\", grammar: MyGrammar())\n}\n\ntry MyPublishSite().publish(using: [\n    ...\n    .installPlugin(.syntaxHighlighting(.myLanguage)),\n])\n```\n\n## Contributions\nContributions are welcome and encouraged!\n\n## License\nSyntaxHighlightPublishPlugin is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdsupremacist%2Fsyntax-highlight-publish-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerdsupremacist%2Fsyntax-highlight-publish-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdsupremacist%2Fsyntax-highlight-publish-plugin/lists"}