Skip to content

Commit

Permalink
add ts file for prism syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Sep 8, 2024
1 parent 954e44c commit b7fe8c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions M2/Macaulay2/editors/make-M2-symbols.m2
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ generateGrammar("atom/macaulay2.cson", symbolsForAtom);

-- Prism: Write macaulay2.js
generateGrammar("prism/macaulay2.js", symbolsForPrism);
generateGrammar("prism/macaulay2.ts", symbolsForPrism);

-- Vim: Write m2.vim.syntax and m2.vim.dict
generateGrammar("vim/m2.vim.syntax", symbolsForVim);
Expand Down
32 changes: 32 additions & 0 deletions M2/Macaulay2/editors/prism/macaulay2.ts.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Prism from "prismjs";

export default [@M2SYMBOLS@].sort(); // used by Macaulay2Web

Prism.languages.m2 =
Prism.languages.macaulay2 = {
'comment': [
{
pattern: /(^|[^\\])\-\*[\s\S]*?(?:\*\-|$)/,
lookbehind: true
},
{
pattern: /(^|[^\\:])\-\-.*/,
lookbehind: true,
greedy: true
}
],
'string': [
{
pattern: /"(?:\\[\s\S]|(?!")[^\\])*"/,
greedy: true
},
{
pattern: /\/\/\/(\/(?!\/)|(?:\/\/)+(?!\/)|[^\/])*(?:\/\/)+\/(?!\/)/,
greedy: true
}
],
'keyword': /\b(?:@M2KEYWORDS@)\b/,
'class-name': /\b(?:@M2DATATYPES@)\b/,
'function': /\b(?:@M2FUNCTIONS@)\b/,
'constant': /\b(?:@M2CONSTANTS@)\b/,
};

0 comments on commit b7fe8c8

Please sign in to comment.