https://github.com/mattmakai/gitbook-plugin-code-highlighter
GitBook plugin. Highlight specific lines in code blocks.
https://github.com/mattmakai/gitbook-plugin-code-highlighter
Last synced: 3 months ago
JSON representation
GitBook plugin. Highlight specific lines in code blocks.
- Host: GitHub
- URL: https://github.com/mattmakai/gitbook-plugin-code-highlighter
- Owner: mattmakai
- License: mit
- Created: 2016-04-19T08:01:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-01T22:31:43.000Z (about 9 years ago)
- Last Synced: 2025-03-17T01:13:18.653Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 62.5 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gitbook-plugin-code-highlighter
[GitBook plugin](https://plugins.gitbook.com/) to highlight specific
lines in code blocks.## Example
Here are a couple of highlighted [Python](https://www.fullstackpython.com/)
code lines using a yellow background:
The above example was generated from these source lines:
```
from os import environ
&&&from fabric.api import *
from fabric.context_managers import cd
&&&from fabric.contrib.files import sed
```## Plugin Installation
1. Make sure you have [GitBook](https://github.com/GitbookIO/gitbook)
and the [gitbook-cli](https://github.com/GitbookIO/gitbook-cli)
installed.1. The default **highlight** plugin that is built into GitBook must be
disabled, because it prevents other plugins from processing code
blocks. Here is an example `book.json` with the highlight plugin
disabled and this code-highlighter plugin enabled.{
"author": "Matthew Makai",
"cover": "cover.jpg",
"gitbook": "2.x.x",
"plugins": ["-highlight", "code-highlighter"],
"title": "The Full Stack Python Guide to Deployments",
"pdf": {
"pageNumbers": true,
"headerTemplate": " ",
"footerTemplate": " "
}
}1. Run `gitbook install` to pull down
[the latest plugin version from NPM](https://www.npmjs.com/package/gitbook-plugin-code-highlighter).## How To Use After Installation
Within a block code prepend `&&&` to each line that should be highlighted.
Then add a `.code-line-highlight` property with a `background-color` to
the `.css` files under the `styles/` directory.For example, your `styles/` directory can contain a `pdf.css` with this line:
.code-line-highlight {background-color: #ffff00;}
That will highlight each selected line in yellow.
For more information on styling, refer to the
[GitBook docs](https://help.gitbook.com/styling/book.html).## More Information
The `&&&` mark and the CSS class can be made configurable, but I have not
added that feature just yet.