mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(highlightjs): integrate terraform
This commit is contained in:
parent
294727600b
commit
6f96a0ef4c
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* highlight.js terraform syntax highlighting definition
|
|
||||||
*
|
|
||||||
* @see https://github.com/highlightjs/highlight.js
|
|
||||||
*
|
|
||||||
* :TODO:
|
|
||||||
*
|
|
||||||
* @package: highlightjs-terraform
|
|
||||||
* @author: Nikos Tsirmirakis <nikos.tsirmirakis@winopsdba.com>
|
|
||||||
* @since: 2019-03-20
|
|
||||||
*
|
|
||||||
* Description: Terraform (HCL) language definition
|
|
||||||
* Category: scripting
|
|
||||||
*/
|
|
||||||
|
|
||||||
var module = module ? module : {}; // shim for browser use
|
|
||||||
|
|
||||||
function hljsDefineTerraform(hljs) {
|
|
||||||
var NUMBERS = {
|
|
||||||
className: 'number',
|
|
||||||
begin: '\\b\\d+(\\.\\d+)?',
|
|
||||||
relevance: 0
|
|
||||||
};
|
|
||||||
var STRINGS = {
|
|
||||||
className: 'string',
|
|
||||||
begin: '"',
|
|
||||||
end: '"',
|
|
||||||
contains: [{
|
|
||||||
className: 'variable',
|
|
||||||
begin: '\\${',
|
|
||||||
end: '\\}',
|
|
||||||
relevance: 9,
|
|
||||||
contains: [{
|
|
||||||
className: 'string',
|
|
||||||
begin: '"',
|
|
||||||
end: '"'
|
|
||||||
}, {
|
|
||||||
className: 'meta',
|
|
||||||
begin: '[A-Za-z_0-9]*' + '\\(',
|
|
||||||
end: '\\)',
|
|
||||||
contains: [
|
|
||||||
NUMBERS, {
|
|
||||||
className: 'string',
|
|
||||||
begin: '"',
|
|
||||||
end: '"',
|
|
||||||
contains: [{
|
|
||||||
className: 'variable',
|
|
||||||
begin: '\\${',
|
|
||||||
end: '\\}',
|
|
||||||
contains: [{
|
|
||||||
className: 'string',
|
|
||||||
begin: '"',
|
|
||||||
end: '"',
|
|
||||||
contains: [{
|
|
||||||
className: 'variable',
|
|
||||||
begin: '\\${',
|
|
||||||
end: '\\}'
|
|
||||||
}]
|
|
||||||
}, {
|
|
||||||
className: 'meta',
|
|
||||||
begin: '[A-Za-z_0-9]*' + '\\(',
|
|
||||||
end: '\\)'
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
'self']
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
aliases: ['tf', 'hcl'],
|
|
||||||
keywords: 'resource variable provider output locals module data terraform|10',
|
|
||||||
literal: 'false true null',
|
|
||||||
contains: [
|
|
||||||
hljs.COMMENT('\\#', '$'),
|
|
||||||
NUMBERS,
|
|
||||||
STRINGS
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hljs.registerLanguage('terraform', hljsDefineTerraform);
|
|
81
packages/highlightjs/src/languages/terraform.ts
Normal file
81
packages/highlightjs/src/languages/terraform.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* highlight.js terraform syntax highlighting definition
|
||||||
|
*
|
||||||
|
* @see https://github.com/highlightjs/highlight.js
|
||||||
|
*
|
||||||
|
* :TODO:
|
||||||
|
*
|
||||||
|
* @package: highlightjs-terraform
|
||||||
|
* @author: Nikos Tsirmirakis <nikos.tsirmirakis@winopsdba.com>
|
||||||
|
* @since: 2019-03-20
|
||||||
|
*
|
||||||
|
* Description: Terraform (HCL) language definition
|
||||||
|
* Category: scripting
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { HLJSApi } from "highlight.js";
|
||||||
|
|
||||||
|
export default function hljsDefineTerraform(hljs: HLJSApi) {
|
||||||
|
var NUMBERS = {
|
||||||
|
className: 'number',
|
||||||
|
begin: '\\b\\d+(\\.\\d+)?',
|
||||||
|
relevance: 0
|
||||||
|
};
|
||||||
|
var STRINGS = {
|
||||||
|
className: 'string',
|
||||||
|
begin: '"',
|
||||||
|
end: '"',
|
||||||
|
contains: [{
|
||||||
|
className: 'variable',
|
||||||
|
begin: '\\${',
|
||||||
|
end: '\\}',
|
||||||
|
relevance: 9,
|
||||||
|
contains: [{
|
||||||
|
className: 'string',
|
||||||
|
begin: '"',
|
||||||
|
end: '"'
|
||||||
|
}, {
|
||||||
|
className: 'meta',
|
||||||
|
begin: '[A-Za-z_0-9]*' + '\\(',
|
||||||
|
end: '\\)',
|
||||||
|
contains: [
|
||||||
|
NUMBERS, {
|
||||||
|
className: 'string',
|
||||||
|
begin: '"',
|
||||||
|
end: '"',
|
||||||
|
contains: [{
|
||||||
|
className: 'variable',
|
||||||
|
begin: '\\${',
|
||||||
|
end: '\\}',
|
||||||
|
contains: [{
|
||||||
|
className: 'string',
|
||||||
|
begin: '"',
|
||||||
|
end: '"',
|
||||||
|
contains: [{
|
||||||
|
className: 'variable',
|
||||||
|
begin: '\\${',
|
||||||
|
end: '\\}'
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
className: 'meta',
|
||||||
|
begin: '[A-Za-z_0-9]*' + '\\(',
|
||||||
|
end: '\\)'
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
'self']
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
aliases: ['tf', 'hcl'],
|
||||||
|
keywords: 'resource variable provider output locals module data terraform|10',
|
||||||
|
literal: 'false true null',
|
||||||
|
contains: [
|
||||||
|
hljs.COMMENT('\\#', '$'),
|
||||||
|
NUMBERS,
|
||||||
|
STRINGS
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ const byMimeType: Record<string, (Mapping | null)> = {
|
|||||||
"application/sparql-query": null,
|
"application/sparql-query": null,
|
||||||
"application/typescript": { loader: import("highlight.js/lib/languages/typescript.js"), alias: "typescript" },
|
"application/typescript": { loader: import("highlight.js/lib/languages/typescript.js"), alias: "typescript" },
|
||||||
"application/x-aspx": null,
|
"application/x-aspx": null,
|
||||||
"application/x-bat": { loader: import("highlight.js/lib/languages/bat.js"), alias: "bat" },
|
"application/x-bat": { loader: import("highlight.js/lib/languages/dos.js"), alias: "bat" },
|
||||||
"application/x-cypher-query": null,
|
"application/x-cypher-query": null,
|
||||||
"application/x-ejs": null,
|
"application/x-ejs": null,
|
||||||
"application/x-erb": { loader: import("highlight.js/lib/languages/erb.js"), alias: "erb" },
|
"application/x-erb": { loader: import("highlight.js/lib/languages/erb.js"), alias: "erb" },
|
||||||
@ -32,7 +32,7 @@ const byMimeType: Record<string, (Mapping | null)> = {
|
|||||||
"text/apl": null,
|
"text/apl": null,
|
||||||
"text/coffeescript": { loader: import("highlight.js/lib/languages/coffeescript.js"), alias: "coffeescript" },
|
"text/coffeescript": { loader: import("highlight.js/lib/languages/coffeescript.js"), alias: "coffeescript" },
|
||||||
"text/css": { loader: import("highlight.js/lib/languages/css.js"), alias: "css" },
|
"text/css": { loader: import("highlight.js/lib/languages/css.js"), alias: "css" },
|
||||||
"text/html": { loader: import("highlight.js/lib/languages/html.js"), alias: "html" },
|
"text/html": { loader: import("highlight.js/lib/languages/xml.js"), alias: "html" },
|
||||||
"text/jinja2": null,
|
"text/jinja2": null,
|
||||||
"text/jsx": { loader: import("highlight.js/lib/languages/javascript.js"), alias: "javascript" },
|
"text/jsx": { loader: import("highlight.js/lib/languages/javascript.js"), alias: "javascript" },
|
||||||
"text/mirc": null,
|
"text/mirc": null,
|
||||||
@ -84,7 +84,7 @@ const byMimeType: Record<string, (Mapping | null)> = {
|
|||||||
"text/x-haml": { loader: import("highlight.js/lib/languages/haml.js"), alias: "haml" },
|
"text/x-haml": { loader: import("highlight.js/lib/languages/haml.js"), alias: "haml" },
|
||||||
"text/x-haskell": { loader: import("highlight.js/lib/languages/haskell.js"), alias: "haskell" },
|
"text/x-haskell": { loader: import("highlight.js/lib/languages/haskell.js"), alias: "haskell" },
|
||||||
"text/x-haxe": { loader: import("highlight.js/lib/languages/haxe.js"), alias: "haxe" },
|
"text/x-haxe": { loader: import("highlight.js/lib/languages/haxe.js"), alias: "haxe" },
|
||||||
"text/x-hcl": { loader: import("highlight.js/lib/languages/terraform.js"), alias: "terraform" },
|
"text/x-hcl": { loader: import("./languages/terraform.js"), alias: "terraform" },
|
||||||
"text/x-hxml": null,
|
"text/x-hxml": null,
|
||||||
"text/x-idl": null,
|
"text/x-idl": null,
|
||||||
"text/x-java": { loader: import("highlight.js/lib/languages/java.js"), alias: "java" },
|
"text/x-java": { loader: import("highlight.js/lib/languages/java.js"), alias: "java" },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user