No description
Find a file
Zhijin Chen 4ed27aad3f
Merge pull request #4 from sena-mike/patch-1
Add platforms to Package.swift
2022-09-06 11:57:50 +09:00
.swiftpm/xcode/package.xcworkspace Trim white spaces and newlines of language name 2020-01-14 15:35:45 +09:00
Sources/SwiftPygmentsPublishPlugin Update to support ```` as code block wrapper 2020-01-22 14:32:13 +09:00
Tests Init Commit 2020-01-14 14:51:52 +09:00
.gitignore Update to support ```` as code block wrapper 2020-01-22 14:32:13 +09:00
LICENSE Init Commit 2020-01-14 14:51:52 +09:00
Package.swift Update Package.swift 2022-09-05 12:09:30 -04:00
README.md Improve readme 2020-01-21 21:55:08 +01:00

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

SwiftPygments uses PythonKit to interact with Pygments.

Installation

  1. Install Python if you don't have it on your system.
  2. Install Pygments if you don't have it on your system.
$ pip3 install pygments
  1. Add SwiftPygmentsPublishPlugin to your package.
let package = Package(
    ...
    dependencies: [
    .package(url: "https://github.com/Ze0nC/SwiftPygmentsPublishPlugin", .branch("master"))
    ],
    targets: [
        .target(
            ...
            dependencies: [
                ...
                "SwiftPygmentsPublishPlugin"
            ]
        )
    ]
    ...
)

Usage

  1. Add .pygments() to your build pipeline.
import SwiftPygmentsPublishPlugin
...
try MyWebsite().publish(using: [
    .installPlugin(.pygments()),
    ...
    .addMarkdownFiles(),
    ...
])
  1. Add a pygments color scheme in your css file. You can find many on internet.

  2. 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