Skip to content

Commit

Permalink
feature: add Solidity highlight support #296
Browse files Browse the repository at this point in the history
  • Loading branch information
meilinz authored and hackjutsu committed Aug 14, 2018
1 parent 2a0668b commit 98cd265
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/containers/codeArea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { Component } from 'react'
import { remote } from 'electron'
import HighlightJS from 'highlight.js'
import hljsDefineSolidity from 'highlightjs-solidity'
import Markdown from '../../utilities/markdown'
import nb from '../../utilities/jupyterNotebook'

Expand All @@ -12,6 +13,7 @@ import './jupyterNotebook.scss'
import './markdown.scss'

const logger = remote.getGlobal('logger')
hljsDefineSolidity(HighlightJS) // register solidity to hightlight.js

export default class CodeArea extends Component {
createJupyterNotebookCodeBlock (content, language, kTabLength) {
Expand Down
6 changes: 5 additions & 1 deletion app/containers/snippet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ class Snippet extends Component {
for (const key in fileList) {
const gistFile = fileList[key]

if (gistFile.filename === '.leptonrc') gistFile.language = 'json'
const filename = gistFile.filename
if (filename === '.leptonrc') gistFile.language = 'json'
else if (filename.endsWith('.sol') || filename.endsWith('.solidity')) {
gistFile.language = 'solidity'
}

fileArray.push(Object.assign({
filename: gistFile.filename,
Expand Down
7 changes: 7 additions & 0 deletions license.json
Original file line number Diff line number Diff line change
Expand Up @@ -3129,6 +3129,13 @@
"path": "/Users/cosmox/CodeBlockProject/Lepton/node_modules/highlight.js",
"licenseFile": "node_modules/highlight.js/LICENSE"
},
"[email protected]": {
"licenses": "MIT",
"repository": "https://github.com/pospi/highlightjs-solidity",
"publisher": "pospi",
"path": "/Users/cosmox/CodeBlockProject/Lepton/node_modules/highlightjs-solidity",
"licenseFile": "node_modules/highlightjs-solidity/README.md"
},
"[email protected]": {
"licenses": "MIT",
"repository": "https://github.com/indutny/hmac-drbg",
Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"electron-window-state": "^4.1.1",
"fuse.js": "^3.0.0",
"highlight.js": "^9.9.0",
"highlightjs-solidity": "^1.0.6",
"human-readable-time": "^0.3.0",
"image-downloader": "^3.2.1",
"markdown-it": "^8.3.2",
Expand Down

0 comments on commit 98cd265

Please sign in to comment.