-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
def64af
commit e29afab
Showing
18 changed files
with
2,649 additions
and
849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /usr/bin/env node | ||
const {makeProgram} = require('./src/cli'); | ||
const { makeProgram } = require('./src/cli') | ||
|
||
makeProgram().parse(); | ||
makeProgram().parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,78 @@ | ||
const md5 = require('md5'); | ||
const guid = require('./support/guid'); | ||
const torchlight = require('./torchlight'); | ||
|
||
let Block = function (opts = {}) { | ||
opts = { | ||
id: guid(), | ||
theme: torchlight.config('theme', 'nord'), | ||
...opts, | ||
} | ||
|
||
this.id = opts.id; | ||
this.code = opts.code; | ||
this.language = opts.language; | ||
this.theme = opts.theme; | ||
|
||
this.highlighted = null; | ||
this.classes = null; | ||
this.styles = null; | ||
const md5 = require('md5') | ||
const guid = require('./support/guid') | ||
const torchlight = require('./torchlight') | ||
|
||
const Block = function (opts = {}) { | ||
opts = { | ||
id: guid(), | ||
theme: torchlight.config('theme', 'nord'), | ||
...opts | ||
} | ||
|
||
this.id = opts.id | ||
this.code = opts.code | ||
this.language = opts.language | ||
this.theme = opts.theme | ||
|
||
this.highlighted = null | ||
this.classes = null | ||
this.styles = null | ||
} | ||
|
||
Block.prototype.hash = function () { | ||
return md5('' | ||
+ this.language | ||
+ this.theme | ||
+ this.code | ||
+ torchlight.config('bust', 0) | ||
+ JSON.stringify(torchlight.config('options')) | ||
) | ||
return md5('' + | ||
this.language + | ||
this.theme + | ||
this.code + | ||
torchlight.config('bust', 0) + | ||
JSON.stringify(torchlight.config('options')) | ||
) | ||
} | ||
|
||
Block.prototype.code = function (code) { | ||
this.code = code; | ||
this.code = code | ||
|
||
return this; | ||
return this | ||
} | ||
|
||
Block.prototype.language = function (language) { | ||
this.language = language; | ||
this.language = language | ||
|
||
return this; | ||
return this | ||
} | ||
|
||
Block.prototype.theme = function (theme) { | ||
this.theme = theme; | ||
this.theme = theme | ||
|
||
return this; | ||
return this | ||
} | ||
|
||
Block.prototype.placeholder = function (extra = '') { | ||
if (extra) { | ||
extra = `-${extra}`; | ||
} | ||
if (extra) { | ||
extra = `-${extra}` | ||
} | ||
|
||
return `__torchlight-block-[${this.id}]${extra}__`; | ||
return `__torchlight-block-[${this.id}]${extra}__` | ||
} | ||
|
||
Block.prototype.setResponseData = function (data) { | ||
if (data) { | ||
this.highlighted = data.highlighted; | ||
this.classes = data.classes; | ||
this.styles = data.styles; | ||
} | ||
if (data) { | ||
this.highlighted = data.highlighted | ||
this.classes = data.classes | ||
this.styles = data.styles | ||
} | ||
|
||
return this; | ||
return this | ||
} | ||
|
||
Block.prototype.toRequestParams = function () { | ||
return { | ||
id: this.id, | ||
hash: this.hash, | ||
language: this.language, | ||
theme: this.theme, | ||
code: this.code, | ||
} | ||
return { | ||
id: this.id, | ||
hash: this.hash, | ||
language: this.language, | ||
theme: this.theme, | ||
code: this.code | ||
} | ||
} | ||
|
||
module.exports = Block; | ||
module.exports = Block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.