https://github.com/jaygooby/jekyll-permalink-for-fenced-code-blocks
https://github.com/jaygooby/jekyll-permalink-for-fenced-code-blocks
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/jaygooby/jekyll-permalink-for-fenced-code-blocks
- Owner: jaygooby
- Created: 2021-02-21T13:00:46.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-21T13:33:51.000Z (over 5 years ago)
- Last Synced: 2025-01-26T17:33:39.324Z (over 1 year ago)
- Language: Ruby
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Description
Adds unique IDs to each fenced code block, so
````
```
echo "wat"
```
````
will render in html as
```
echo "wat"
```
And then you can link to it using `` or add a [ClipboardJS](https://clipboardjs.com) hook using the `#code-1` ID attribute.
# Usage
Drop `permalink-for-fenced-code-blocks.rb` into your Jekyll `_plugins` folder. By default, you'll also get a `` element for each code block, that looks like:
```
copy to clipboard
```
which you can hook up with [ClipboardJS](https://clipboardjs.com/#usage). If you don't want this `button` element, start Jekyll like this:
```
NO_COPY_BUTTON=1 jekyll serve -w
```