Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit cf2d61a

Browse files
Merge pull request #3 from deckgo/terminal
feat: new terminal options
2 parents e73a31e + 828f873 commit cf2d61a

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed

README.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,24 @@ Adds stylish cards and syntax highlighting to code blocks in markdown files usin
44

55
This code highlighter is developed with [Stencil](https://stenciljs.com) and use [Prism.js](https://prismjs.com) under the hood.
66

7-
Furthermore, the inspiration for the design of the cards comes from the amazing [carbon](https://carbon.now.sh), a tool to create and share beautiful images of your source code.
7+
The inspiration for the design of the "Macish" cards comes from the amazing [carbon](https://carbon.now.sh), a tool to create and share beautiful images of your source code, and for the "Ubuntu-ish" from the [article](https://dev.to/codypearce/ubuntu-terminal-in-css-1aeo) of [Cody Pearce](https://twitter.com/codyapearce).
88

9-
<div align="center">
10-
<img src="static/screenshot.png" alt="Syntax highlighting code block as card" width="100%">
9+
Carbon:
10+
11+
<div align="left">
12+
<img src="static/screenshot-carbon.png" alt="Syntax highlighting code block as Carbon card" width="100%">
13+
</div>
14+
15+
Ubuntu:
16+
17+
<div align="left">
18+
<img src="static/screenshot-ubuntu.png" alt="Syntax highlighting code block as Ubuntu card" width="100%">
19+
</div>
20+
21+
None:
22+
23+
<div align="left">
24+
<img src="static/screenshot-none.png" alt="Syntax highlighting code block" width="100%">
1125
</div>
1226

1327
## Table of contents
@@ -18,6 +32,8 @@ Furthermore, the inspiration for the design of the cards comes from the amazing
1832
- [Load the component](#load-the-component)
1933
- [Language](#language)
2034
- [Styling](#styling)
35+
- [Terminal](#terminal)
36+
- [Variables](#variables)
2137
- [Showcase](#showcase)
2238
- [License](#license)
2339

@@ -75,6 +91,37 @@ This plugin supports all languages supported by [Prism.js](https://prismjs.com).
7591

7692
## Styling
7793

94+
Code blocks are displayed in stylish cards but the behavior could be customized.
95+
96+
### Terminal
97+
98+
Per default, code blocks are going to be displayed in `carbon` ("Macish like") container.
99+
100+
It is also possible to use `ubuntu` (an Ubuntu-like container) or `none` (no window container).
101+
102+
Such settings can be provided in the configuration of the plugin.
103+
104+
```javascript
105+
// In your gatsby-config.js
106+
plugins: [
107+
{
108+
resolve: `gatsby-transformer-remark`,
109+
options: {
110+
plugins: [
111+
{
112+
resolve: `gatsby-remark-highlight-code`,
113+
options: {
114+
terminal: 'ubuntu'
115+
}
116+
},
117+
],
118+
},
119+
},
120+
]
121+
```
122+
123+
### Variables
124+
78125
See the [@deckdeckgo/highlight-code] documentation for the list of CSS4 styling variables.
79126

80127
## Showcase

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ const toString = require("mdast-util-to-string")
33

44
const _ = require(`lodash`)
55

6-
module.exports = ({ markdownAST }, _pluginOptions) => {
6+
module.exports = ({ markdownAST }, pluginOptions) => {
7+
8+
const terminal = pluginOptions && pluginOptions.terminal && pluginOptions.terminal !== '' ? pluginOptions.terminal : undefined
9+
710
visit(markdownAST, "code", node => {
811
const text = toString(node)
912

1013
const html = `
11-
<deckgo-highlight-code ${node && node.lang !== null ? `language="${node.lang}"` : ''}>
14+
<deckgo-highlight-code ${node && node.lang !== null ? `language="${node.lang}"` : ''} ${terminal !== undefined ? `terminal="${terminal}"` : ''}>
1215
<code slot="code">${_.escape(text)}</code>
1316
</deckgo-highlight-code>
1417
`

static/screenshot-carbon.png

58.5 KB
Loading

static/screenshot-none.png

19.3 KB
Loading

static/screenshot-ubuntu.png

44.9 KB
Loading

static/screenshot.png

-30.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)