mirror of
https://github.com/Ze0nC/SwiftPygmentsPublishPlugin.git
synced 2026-04-03 00:28:29 -06:00
No description
|
|
||
|---|---|---|
| .swiftpm/xcode/package.xcworkspace | ||
| Sources/SwiftPygmentsPublishPlugin | ||
| Tests | ||
| .gitignore | ||
| LICENSE | ||
| Package.swift | ||
| README.md | ||
SwiftPygments Plugin for Publish
A Pygments plugin for Publish to highlight code.
Pygments is a syntax highlighting tool made in Python that supports many languages.
Requirements
PythonPygments: https://pygments.orgSwift 5- Pygments color scheme in your .css file
SwiftPygments uses PythonKit to interact with Pygments.
Installation
- Install
Pythonif you don't have it on your system. - Install
Pygmentsif you don't have it on your system.
$ pip3 install pygments
- Add
SwiftPygmentsPublishPluginto your package.
let package = Package(
...
dependencies: [
.package(url: "https://github.com/Ze0nC/SwiftPygmentsPublishPlugin", .branch("master"))
],
targets: [
.target(
...
dependencies: [
...
"SwiftPygmentsPublishPlugin"
]
)
]
...
)
Usage
- Add
.pygments()to your build pipeline.
import SwiftPygmentsPublishPlugin
...
try MyWebsite().publish(using: [
.installPlugin(.pygments()),
...
.addMarkdownFiles(),
...
])
-
Add a pygments color scheme in your
cssfile. You can find many on internet. -
Write highlighted codes!
In your markdown file, specify language after ``` to get correct highlight.
```swift
let str = "This is Swift code."
print(str)
```
Specify code as python
```python
str = "This is also Swift code."
print(str)
```
If no language is specified, swift syntax will be used as default.
```
let str = "This is also Swift code."
print(str)
```
Note
This plugin will highlight all code block but not inline codes.
Enjoy your highlighted sites!
Acknowledgement
Thanks to John Sundell (@johnsundell) for creating Publish and SplashPublishPlugin
License
MIT License