初始化
This commit is contained in:
1
towxml/parse/highlight/highlight.js
Normal file
1
towxml/parse/highlight/highlight.js
Normal file
File diff suppressed because one or more lines are too long
8
towxml/parse/highlight/index.js
Normal file
8
towxml/parse/highlight/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const config = require('../../config'),
|
||||
hljs = require('./highlight');
|
||||
// config.highlight.forEach(item => {
|
||||
// hljs.registerLanguage(item, require(`./languages/${item}`).default);
|
||||
// });
|
||||
hljs.registerLanguage('bash', require('./languages/bash').default);
|
||||
|
||||
module.exports = hljs;
|
||||
111
towxml/parse/highlight/languages/bash.js
Normal file
111
towxml/parse/highlight/languages/bash.js
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Language: Bash
|
||||
Author: vah <vahtenberg@gmail.com>
|
||||
Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
|
||||
Website: https://www.gnu.org/software/bash/
|
||||
Category: common
|
||||
*/
|
||||
|
||||
export default function(hljs) {
|
||||
const VAR = {};
|
||||
const BRACED_VAR = {
|
||||
begin: /\$\{/, end:/\}/,
|
||||
contains: [
|
||||
{ begin: /:-/, contains: [VAR] } // default values
|
||||
]
|
||||
};
|
||||
Object.assign(VAR,{
|
||||
className: 'variable',
|
||||
variants: [
|
||||
{begin: /\$[\w\d#@][\w\d_]*/},
|
||||
BRACED_VAR
|
||||
]
|
||||
});
|
||||
|
||||
const SUBST = {
|
||||
className: 'subst',
|
||||
begin: /\$\(/, end: /\)/,
|
||||
contains: [hljs.BACKSLASH_ESCAPE]
|
||||
};
|
||||
const QUOTE_STRING = {
|
||||
className: 'string',
|
||||
begin: /"/, end: /"/,
|
||||
contains: [
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
VAR,
|
||||
SUBST
|
||||
]
|
||||
};
|
||||
SUBST.contains.push(QUOTE_STRING);
|
||||
const ESCAPED_QUOTE = {
|
||||
className: '',
|
||||
begin: /\\"/
|
||||
|
||||
};
|
||||
const APOS_STRING = {
|
||||
className: 'string',
|
||||
begin: /'/, end: /'/
|
||||
};
|
||||
const ARITHMETIC = {
|
||||
begin: /\$\(\(/,
|
||||
end: /\)\)/,
|
||||
contains: [
|
||||
{ begin: /\d+#[0-9a-f]+/, className: "number" },
|
||||
hljs.NUMBER_MODE,
|
||||
VAR
|
||||
]
|
||||
};
|
||||
const SHEBANG = {
|
||||
className: 'meta',
|
||||
begin: /^#![^\n]+sh\s*$/,
|
||||
relevance: 10
|
||||
};
|
||||
const FUNCTION = {
|
||||
className: 'function',
|
||||
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
|
||||
returnBegin: true,
|
||||
contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
|
||||
relevance: 0
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'Bash',
|
||||
aliases: ['sh', 'zsh'],
|
||||
lexemes: /\b-?[a-z\._]+\b/,
|
||||
keywords: {
|
||||
keyword:
|
||||
'if then else elif fi for while in do done case esac function',
|
||||
literal:
|
||||
'true false',
|
||||
built_in:
|
||||
// Shell built-ins
|
||||
// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
||||
'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' +
|
||||
'trap umask unset ' +
|
||||
// Bash built-ins
|
||||
'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' +
|
||||
'read readarray source type typeset ulimit unalias ' +
|
||||
// Shell modifiers
|
||||
'set shopt ' +
|
||||
// Zsh built-ins
|
||||
'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' +
|
||||
'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' +
|
||||
'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' +
|
||||
'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' +
|
||||
'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' +
|
||||
'zpty zregexparse zsocket zstyle ztcp',
|
||||
_:
|
||||
'-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster
|
||||
},
|
||||
contains: [
|
||||
SHEBANG,
|
||||
FUNCTION,
|
||||
ARITHMETIC,
|
||||
hljs.HASH_COMMENT_MODE,
|
||||
QUOTE_STRING,
|
||||
ESCAPED_QUOTE,
|
||||
APOS_STRING,
|
||||
VAR
|
||||
]
|
||||
};
|
||||
}
|
||||
99
towxml/parse/highlight/style/github.wxss
Normal file
99
towxml/parse/highlight/style/github.wxss
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
|
||||
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
||||
|
||||
*/
|
||||
|
||||
.h2w-light .hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
color: #333;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-comment,
|
||||
.h2w-light .hljs-quote {
|
||||
color: #998;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-keyword,
|
||||
.h2w-light .hljs-selector-tag,
|
||||
.h2w-light .hljs-subst {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-number,
|
||||
.h2w-light .hljs-literal,
|
||||
.h2w-light .hljs-variable,
|
||||
.h2w-light .hljs-template-variable,
|
||||
.h2w-light .hljs-tag .hljs-attr {
|
||||
color: #008080;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-string,
|
||||
.h2w-light .hljs-doctag {
|
||||
color: #d14;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-title,
|
||||
.h2w-light .hljs-section,
|
||||
.h2w-light .hljs-selector-id {
|
||||
color: #900;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-subst {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-type,
|
||||
.h2w-light .hljs-class .hljs-title {
|
||||
color: #458;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-tag,
|
||||
.h2w-light .hljs-name,
|
||||
.h2w-light .hljs-attribute {
|
||||
color: #000080;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-regexp,
|
||||
.h2w-light .hljs-link {
|
||||
color: #009926;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-symbol,
|
||||
.h2w-light .hljs-bullet {
|
||||
color: #990073;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-built_in,
|
||||
.h2w-light .hljs-builtin-name {
|
||||
color: #0086b3;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-meta {
|
||||
color: #999;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-deletion {
|
||||
background: #fdd;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-addition {
|
||||
background: #dfd;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.h2w-light .hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
70
towxml/parse/highlight/style/monokai.wxss
Normal file
70
towxml/parse/highlight/style/monokai.wxss
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Monokai style - ported by Luigi Maselli - http://grigio.org
|
||||
*/
|
||||
|
||||
.h2w-dark .hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: #272822; color: #ddd;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-tag,
|
||||
.h2w-dark .hljs-keyword,
|
||||
.h2w-dark .hljs-selector-tag,
|
||||
.h2w-dark .hljs-literal,
|
||||
.h2w-dark .hljs-strong,
|
||||
.h2w-dark .hljs-name {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-code {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-class .hljs-title {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-attribute,
|
||||
.h2w-dark .hljs-symbol,
|
||||
.h2w-dark .hljs-regexp,
|
||||
.h2w-dark .hljs-link {
|
||||
color: #bf79db;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-string,
|
||||
.h2w-dark .hljs-bullet,
|
||||
.h2w-dark .hljs-subst,
|
||||
.h2w-dark .hljs-title,
|
||||
.h2w-dark .hljs-section,
|
||||
.h2w-dark .hljs-emphasis,
|
||||
.h2w-dark .hljs-type,
|
||||
.h2w-dark .hljs-built_in,
|
||||
.h2w-dark .hljs-builtin-name,
|
||||
.h2w-dark .hljs-selector-attr,
|
||||
.h2w-dark .hljs-selector-pseudo,
|
||||
.h2w-dark .hljs-addition,
|
||||
.h2w-dark .hljs-variable,
|
||||
.h2w-dark .hljs-template-tag,
|
||||
.h2w-dark .hljs-template-variable {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-comment,
|
||||
.h2w-dark .hljs-quote,
|
||||
.h2w-dark .hljs-deletion,
|
||||
.h2w-dark .hljs-meta {
|
||||
color: #75715e;
|
||||
}
|
||||
|
||||
.h2w-dark .hljs-keyword,
|
||||
.h2w-dark .hljs-selector-tag,
|
||||
.h2w-dark .hljs-literal,
|
||||
.h2w-dark .hljs-doctag,
|
||||
.h2w-dark .hljs-title,
|
||||
.h2w-dark .hljs-section,
|
||||
.h2w-dark .hljs-type,
|
||||
.h2w-dark .hljs-selector-id {
|
||||
font-weight: bold;
|
||||
}
|
||||
Reference in New Issue
Block a user