-
Notifications
You must be signed in to change notification settings - Fork 452
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
9527ef6
commit 9fdaba2
Showing
8 changed files
with
45 additions
and
198 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const fs = require('fs'); | ||
|
||
function parse(file) { | ||
let css = fs.readFileSync(file).toString(); | ||
let rule = ''; | ||
let background = ''; | ||
let foreground = ''; | ||
css.replace(/\.hljs([^\S]+|,[^\{]+)\{(.*?)\}/sg, (match, $1, content) => { | ||
rule += content; | ||
return match; | ||
}); | ||
rule.split('\n').forEach(line => { | ||
if (line.includes('background:')) background = line.split('background:')[1]; | ||
else if (line.includes('background-color:')) background = line.split('background-color:')[1]; | ||
else if (line.includes('color:')) foreground = line.split('color:')[1]; | ||
}); | ||
return { | ||
file, | ||
background, | ||
foreground | ||
}; | ||
} | ||
|
||
module.exports = hexo => { | ||
hexo.config.highlight.hljs = false; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
stevenjoezhang
Author
Member
|
||
let file = `${hexo.plugin_dir}highlight.js/styles/${hexo.theme.config.codeblock.highlight_theme}.css`; | ||
hexo.theme.config.highlight = parse(file); | ||
}; |
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 was deleted.
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 was deleted.
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
Why is this set false here? I had to remove this line to make highlight work.