mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(highlighting): add dylan
This commit is contained in:
parent
a520e72a15
commit
b80ca1eef2
@ -48,6 +48,7 @@
|
||||
* Added support for SystemVerilog.
|
||||
* Added support for mIRC.
|
||||
* Added support for Cobol.
|
||||
* Added support for Dylan.
|
||||
* Mermaid diagrams: basic syntax highlight (not all diagram types are supported) and code folding.
|
||||
* Slight organization in Appearance settings: code block themes are now in "Text Notes", added a "Related settings" section in Appearance.
|
||||
* [Added support for opening and activating a note in a new tab using Ctrl+Shift+click on notes in the launcher pane, note tree, or note images](https://github.com/TriliumNext/Notes/pull/1854) by @SiriusXT
|
||||
|
76
packages/highlightjs/src/languages/dylan.ts
Normal file
76
packages/highlightjs/src/languages/dylan.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import type { HLJSApi, Language, Mode } from "highlight.js";
|
||||
|
||||
/*
|
||||
* highlight.js Dylan syntax highlighting definition
|
||||
*
|
||||
* Source: https://github.com/highlightjs/highlightjs-dylan/blob/master/src/dylan.js
|
||||
*
|
||||
* @see https://github.com/highlightjs/highlight.js
|
||||
* @see https://opendylan.org/
|
||||
*
|
||||
* :TODO:
|
||||
*
|
||||
* @package: highlightjs-dylan
|
||||
* @author: Peter Hull <peterhull90@gmail.com>
|
||||
* @since: 2019-04-08
|
||||
*
|
||||
* Description: Dylan language definition
|
||||
* Category: functional
|
||||
*/
|
||||
|
||||
export default function(hljs: HLJSApi): Language {
|
||||
const DYLAN_CORE_WORDS = ["define", "end", "handler", "let", "local", "macro", "otherwise"];
|
||||
const DYLAN_BEGIN_WORDS = ["begin", "block", "case", "for", "if", "method",
|
||||
"select", "unless", "until", "while"
|
||||
];
|
||||
const DYLAN_FUNCTION_WORDS: string[] = [];
|
||||
const DYLAN_DEFINE_BODY_WORDS = ["class", "library", "method", "module"];
|
||||
const DYLAN_DEFINE_LIST_WORDS = ["constant", "variable", "domain"];
|
||||
const DYLAN_RESERVED_WORDS = ([] as string[]).concat(DYLAN_CORE_WORDS,
|
||||
DYLAN_BEGIN_WORDS,
|
||||
DYLAN_FUNCTION_WORDS,
|
||||
DYLAN_DEFINE_BODY_WORDS.map(function(word) {
|
||||
return word + '|2';
|
||||
}),
|
||||
DYLAN_DEFINE_LIST_WORDS
|
||||
);
|
||||
const DYLAN_HASH_WORDS = ["#t", "#f", "#next", "#rest", "#key", "#all-keys", "#include"];
|
||||
const DYLAN_WORD = '[a-z\-+\*/^=#!%$_><@\?~][a-z0-9\-+\*/^=#!%$_><@\?~]*';
|
||||
const KEYWORDS = {
|
||||
$pattern: DYLAN_WORD,
|
||||
literal: DYLAN_HASH_WORDS.join(" "),
|
||||
keyword: DYLAN_RESERVED_WORDS.join(" ")
|
||||
};
|
||||
const DYLAN_CODE = {
|
||||
case_insensitive: true,
|
||||
className: 'dylan',
|
||||
keywords: KEYWORDS,
|
||||
contains: [{
|
||||
className: 'class',
|
||||
begin: '<' + DYLAN_WORD + '>',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: '#' + DYLAN_WORD
|
||||
},
|
||||
{
|
||||
className: 'symbol',
|
||||
begin: DYLAN_WORD + ':',
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'string',
|
||||
begin: '\'\\\\?.',
|
||||
end: '\'',
|
||||
illegal: '.'
|
||||
},
|
||||
hljs.C_NUMBER_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE
|
||||
]
|
||||
};
|
||||
|
||||
return DYLAN_CODE;
|
||||
};
|
@ -60,7 +60,7 @@ const byMimeType: MimeRecord = {
|
||||
"text/x-diff": () => import("highlight.js/lib/languages/diff"),
|
||||
"text/x-django": () => import("highlight.js/lib/languages/django"),
|
||||
"text/x-dockerfile": () => import("highlight.js/lib/languages/dockerfile"),
|
||||
"text/x-dylan": null,
|
||||
"text/x-dylan": () => import("./languages/dylan.js"),
|
||||
"text/x-ebnf": () => import("highlight.js/lib/languages/ebnf"),
|
||||
"text/x-ecl": null,
|
||||
"text/x-eiffel": null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user