diff --git a/package-lock.json b/package-lock.json index 5ad516a..1874225 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0-dev", "devDependencies": { "@codemirror/commands": "^6.1.2", + "@codemirror/lang-cpp": "^6.0.2", "@codemirror/lang-html": "^6.4.0", "@codemirror/lang-java": "^6.0.1", "@codemirror/lang-javascript": "^6.1.2", @@ -17,7 +18,9 @@ "@codemirror/lang-markdown": "^6.0.5", "@codemirror/lang-php": "^6.0.1", "@codemirror/lang-python": "^6.1.1", + "@codemirror/lang-rust": "^6.0.1", "@codemirror/lang-sql": "^6.3.3", + "@codemirror/lang-xml": "^6.0.2", "@codemirror/language": "^6.4.0", "@codemirror/rangeset": "^0.19.9", "@codemirror/search": "^6.2.3", @@ -79,6 +82,16 @@ "@lezer/common": "^1.0.0" } }, + "node_modules/@codemirror/lang-cpp": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-cpp/-/lang-cpp-6.0.2.tgz", + "integrity": "sha512-6oYEYUKHvrnacXxWxYa6t4puTlbN3dgV662BDfSH8+MfjQjVmP697/KYTDOqpxgerkvoNm7q5wlFMBeX8ZMocg==", + "dev": true, + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/cpp": "^1.0.0" + } + }, "node_modules/@codemirror/lang-css": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.0.1.tgz", @@ -193,6 +206,16 @@ "@lezer/python": "^1.0.0" } }, + "node_modules/@codemirror/lang-rust": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@codemirror/lang-rust/-/lang-rust-6.0.1.tgz", + "integrity": "sha512-344EMWFBzWArHWdZn/NcgkwMvZIWUR1GEBdwG8FEp++6o6vT6KL9V7vGs2ONsKxxFUPXKI0SPcWhyYyl2zPYxQ==", + "dev": true, + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/rust": "^1.0.0" + } + }, "node_modules/@codemirror/lang-sql": { "version": "6.3.3", "resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-6.3.3.tgz", @@ -206,6 +229,19 @@ "@lezer/lr": "^1.0.0" } }, + "node_modules/@codemirror/lang-xml": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.0.2.tgz", + "integrity": "sha512-JQYZjHL2LAfpiZI2/qZ/qzDuSqmGKMwyApYmEUUCTxLM4MWS7sATUEfIguZQr9Zjx/7gcdnewb039smF6nC2zw==", + "dev": true, + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.4.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/xml": "^1.0.0" + } + }, "node_modules/@codemirror/language": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.4.0.tgz", @@ -756,6 +792,16 @@ "integrity": "sha512-SVgiGtMnMnW3ActR8SXgsDhw7a0w0ChHSYAyAUxxrOiJ1OqYWEKk/xJd84tTSPo1mo6DXLObAJALNnd0Hrv7Ng==", "dev": true }, + "node_modules/@lezer/cpp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@lezer/cpp/-/cpp-1.0.0.tgz", + "integrity": "sha512-Klk3/AIEKoptmm6cNm7xTulNXjdTKkD+hVOEcz/NeRg8tIestP5hsGHJeFDR/XtyDTxsjoPjKZRIGohht7zbKw==", + "dev": true, + "dependencies": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, "node_modules/@lezer/css": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.1.1.tgz", @@ -878,6 +924,26 @@ "@lezer/lr": "^1.0.0" } }, + "node_modules/@lezer/rust": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@lezer/rust/-/rust-1.0.0.tgz", + "integrity": "sha512-IpGAxIjNxYmX9ra6GfQTSPegdCAWNeq23WNmrsMMQI7YNSvKtYxO4TX5rgZUmbhEucWn0KTBMeDEPXg99YKtTA==", + "dev": true, + "dependencies": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-jMDXrV953sDAUEMI25VNrI9dz94Ai96FfeglytFINhhwQ867HKlCE2jt3AwZTCT7M528WxdDWv/Ty8e9wizwmQ==", + "dev": true, + "dependencies": { + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, "node_modules/@malept/cross-spawn-promise": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-1.1.1.tgz", diff --git a/package.json b/package.json index ca23ec1..548885d 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ }, "devDependencies": { "@codemirror/commands": "^6.1.2", + "@codemirror/lang-cpp": "^6.0.2", "@codemirror/lang-html": "^6.4.0", "@codemirror/lang-java": "^6.0.1", "@codemirror/lang-javascript": "^6.1.2", @@ -35,7 +36,9 @@ "@codemirror/lang-markdown": "^6.0.5", "@codemirror/lang-php": "^6.0.1", "@codemirror/lang-python": "^6.1.1", + "@codemirror/lang-rust": "^6.0.1", "@codemirror/lang-sql": "^6.3.3", + "@codemirror/lang-xml": "^6.0.2", "@codemirror/language": "^6.4.0", "@codemirror/rangeset": "^0.19.9", "@codemirror/search": "^6.2.3", diff --git a/public/langdetect-worker.js b/public/langdetect-worker.js index 8e15ddb..cb14f87 100644 --- a/public/langdetect-worker.js +++ b/public/langdetect-worker.js @@ -1,6 +1,20 @@ importScripts("highlight.min.js") -const HIGHLIGHTJS_LANGUAGES = ["json", "python", "javascript", "html", "sql", "java", "plaintext"] +const HIGHLIGHTJS_LANGUAGES = [ + "json", + "python", + "javascript", + "html", + "sql", + "java", + "plaintext", + "cpp", + "php", + "css", + "markdown", + "xml", + "rust", +] onmessage = (event) => { //console.log("worker received message:", event.data) diff --git a/src/editor/lang-heynote/heynote.grammar b/src/editor/lang-heynote/heynote.grammar index 2f51d6b..bc66000 100644 --- a/src/editor/lang-heynote/heynote.grammar +++ b/src/editor/lang-heynote/heynote.grammar @@ -11,7 +11,7 @@ NoteDelimiter { @tokens { noteDelimiterMark { "∞∞∞" } - NoteLanguage { "text" | "javascript" | "json" | "python" | "html" | "sql" | "markdown" | "java" | "lezer" | "php" | "css" } + NoteLanguage { "text" | "javascript" | "json" | "python" | "html" | "sql" | "markdown" | "java" | "php" | "css" | "xml" | "cpp" | "rust" } Auto { "-a" } noteDelimiterEnter { "\n" } //NoteContent { String } diff --git a/src/editor/lang-heynote/parser.js b/src/editor/lang-heynote/parser.js index ce07869..f042d53 100644 --- a/src/editor/lang-heynote/parser.js +++ b/src/editor/lang-heynote/parser.js @@ -10,7 +10,7 @@ export const parser = LRParser.deserialize({ maxTerm: 10, skippedNodes: [0], repeatNodeCount: 1, - tokenData: "'S~RZYZt}!Oy#V#W!U#[#]!g#^#_!y#`#a$d#a#b$|#d#e%r#g#h&_#h#i&e%&x%&y&q~yOX~~|P#T#U!P~!UOU~~!XP#g#h![~!_P#g#h!b~!gOT~~!jP#h#i!m~!pP#a#b!s~!vP#`#a!b~!|Q#T#U#S#g#h$W~#VP#j#k#Y~#]P#T#U#`~#ePT~#g#h#h~#kP#V#W#n~#qP#f#g#t~#wP#]#^#z~#}P#d#e$Q~$TP#h#i!b~$ZP#c#d$^~$aP#b#c!b~$gP#X#Y$j~$mP#n#o$p~$sP#X#Y$v~$yP#f#g!b~%PP#T#U%S~%VP#f#g%Y~%]P#_#`%`~%cP#W#X%f~%iP#c#d%l~%oP#k#l$^~%uQ#[#]%{#m#n&R~&OP#d#e!b~&UP#h#i&X~&[P#[#]$W~&bP#e#f!s~&hP#X#Y&k~&nP#l#m$Q~&tP%&x%&y&w~&zP%&x%&y&}~'SOY~", + tokenData: "&|~R[YZw}!O|#V#W!X#[#]!s#^#_#V#a#b$p#d#e%f#f#g%{#g#h&X#h#i&_#l#m!y%&x%&y&k~|OX~~!PP#T#U!S~!XOU~~![Q#d#e!b#g#h!m~!eP#d#e!h~!mOT~~!pP#g#h!h~!vP#h#i!y~!|P#a#b#P~#SP#`#a!h~#YQ#T#U#`#g#h$d~#cP#j#k#f~#iP#T#U#l~#qPT~#g#h#t~#wP#V#W#z~#}P#f#g$Q~$TP#]#^$W~$ZP#d#e$^~$aP#h#i!h~$gP#c#d$j~$mP#b#c!h~$sP#T#U$v~$yP#f#g$|~%PP#_#`%S~%VP#W#X%Y~%]P#c#d%`~%cP#k#l$j~%iQ#[#]!b#m#n%o~%rP#h#i%u~%xP#[#]$d~&OP#i#j&R~&UP#g#h$^~&[P#e#f#P~&bP#X#Y&e~&hP#l#m$^~&nP%&x%&y&q~&tP%&x%&y&w~&|OY~", tokenizers: [0, noteContent], topRules: {"Document":[0,2]}, tokenPrec: 0 diff --git a/src/editor/languages.js b/src/editor/languages.js index 97de374..e7cdc62 100644 --- a/src/editor/languages.js +++ b/src/editor/languages.js @@ -8,6 +8,9 @@ import { javaLanguage } from "@codemirror/lang-java" import { lezerLanguage } from "@codemirror/lang-lezer" import { phpLanguage } from "@codemirror/lang-php" import { cssLanguage } from "@codemirror/lang-css" +import { cppLanguage } from "@codemirror/lang-cpp" +import { xmlLanguage } from "@codemirror/lang-xml" +import { rustLanguage } from "@codemirror/lang-rust" class Language { @@ -28,8 +31,12 @@ export const LANGUAGES = [ new Language("sql", "SQL", StandardSQL.language.parser, "sql"), new Language("markdown", "Markdown", markdownLanguage.parser, "markdown"), new Language("java", "Java", javaLanguage.parser, "java"), - new Language("lezer", "Lezer", lezerLanguage.parser, "lezer"), + //new Language("lezer", "Lezer", lezerLanguage.parser, "lezer"), new Language("php", "PHP", phpLanguage.parser, "php"), new Language("css", "CSS", cssLanguage.parser, "css"), + new Language("xml", "XML", xmlLanguage.parser, "xml"), + new Language("cpp", "C++", cppLanguage.parser, "cpp"), + new Language("rust", "Rust", rustLanguage.parser, "rust"), + ]