Commit cbacf5b6 authored by Konrad Borowski's avatar Konrad Borowski

Update language identifiers

This is the last moment to do this, as the /v1/pastes API
will become public soon.
parent f41a6d65
Pipeline #93446893 passed with stage
in 6 minutes and 35 seconds
......@@ -2,31 +2,31 @@ import * as CodeMirror from 'codemirror'
import 'codemirror/lib/codemirror.css'
import './codemirror.css'
const languagesMap: Map<string, [() => Promise<void> | void, string]> = new Map([
['c', [() => import('codemirror/mode/clike/clike'), 'text/x-csrc']],
['c-plus-plus', [() => import('codemirror/mode/clike/clike'), 'text/x-c++src']],
['c-sharp', [() => import('codemirror/mode/clike/clike'), 'text/x-csharp']],
['haskell', [() => import('codemirror/mode/haskell/haskell'), 'text/x-haskell']],
['html', [() => import('codemirror/mode/htmlmixed/htmlmixed'), 'text/html']],
['java', [() => import('codemirror/mode/clike/clike'), 'text/x-java']],
['javascript', [() => import('codemirror/mode/javascript/javascript'), 'text/javascript']],
['jinja2', [() => import('codemirror/mode/jinja2/jinja2'), 'text/jinja2']],
['jsx', [() => import('codemirror/mode/jsx/jsx'), 'text/jsx']],
['markdown', [() => import('codemirror/mode/markdown/markdown'), 'text/x-markdown']],
['perl', [() => import('codemirror/mode/perl/perl'), 'text/x-perl']],
['php', [() => import('codemirror/mode/php/php'), 'application/x-httpd-php']],
['plain-text', [() => { }, 'text/plain']],
['postgresql', [() => import('codemirror/mode/sql/sql'), 'text/x-pgsql']],
['python2', [() => import('codemirror/mode/python/python'), 'text/x-python']],
['python3', [() => import('codemirror/mode/python/python'), 'text/x-python']],
['raku', [() => import('./raku'), 'text/x-raku']],
['rust', [() => import('codemirror/mode/rust/rust'), 'text/x-rustsrc']],
['sh', [() => import('codemirror/mode/shell/shell'), 'text/x-sh']],
['sql', [() => import('codemirror/mode/sql/sql'), 'text/x-sql']],
['sqlite', [() => import('codemirror/mode/sql/sql'), 'text/x-sqlite']],
['typescript', [() => import('codemirror/mode/javascript/javascript'), 'application/typescript']],
['typescript-jsx', [() => import('codemirror/mode/jsx/jsx'), 'text/typescript-jsx']],
])
const languagesMap = {
c: [() => import('codemirror/mode/clike/clike'), 'text/x-csrc'],
cpp: [() => import('codemirror/mode/clike/clike'), 'text/x-c++src'],
csharp: [() => import('codemirror/mode/clike/clike'), 'text/x-csharp'],
haskell: [() => import('codemirror/mode/haskell/haskell'), 'text/x-haskell'],
html: [() => import('codemirror/mode/htmlmixed/htmlmixed'), 'text/html'],
java: [() => import('codemirror/mode/clike/clike'), 'text/x-java'],
javascript: [() => import('codemirror/mode/javascript/javascript'), 'text/javascript'],
jinja2: [() => import('codemirror/mode/jinja2/jinja2'), 'text/jinja2'],
jsx: [() => import('codemirror/mode/jsx/jsx'), 'text/jsx'],
markdown: [() => import('codemirror/mode/markdown/markdown'), 'text/x-markdown'],
perl: [() => import('codemirror/mode/perl/perl'), 'text/x-perl'],
php: [() => import('codemirror/mode/php/php'), 'application/x-httpd-php'],
plaintext: [() => { }, 'text/plain'],
postgresql: [() => import('codemirror/mode/sql/sql'), 'text/x-pgsql'],
python2: [() => import('codemirror/mode/python/python'), 'text/x-python'],
python: [() => import('codemirror/mode/python/python'), 'text/x-python'],
raku: [() => import('./raku'), 'text/x-raku'],
rust: [() => import('codemirror/mode/rust/rust'), 'text/x-rustsrc'],
sh: [() => import('codemirror/mode/shell/shell'), 'text/x-sh'],
sql: [() => import('codemirror/mode/sql/sql'), 'text/x-sql'],
sqlite: [() => import('codemirror/mode/sql/sql'), 'text/x-sqlite'],
typescript: [() => import('codemirror/mode/javascript/javascript'), 'application/typescript'],
tsx: [() => import('codemirror/mode/jsx/jsx'), 'text/typescript-jsx'],
}
class CodeMirrorEditor {
editor: CodeMirror.EditorFromTextArea
......@@ -38,7 +38,7 @@ class CodeMirrorEditor {
async setLanguage(identifier) {
this.currentIdentifier = identifier
const [importFn, mime] = await languagesMap.get(identifier)
const [importFn, mime] = languagesMap[identifier]
this.editor.setOption('mode', mime)
await importFn()
if (this.currentIdentifier === identifier) {
......
......@@ -26,28 +26,29 @@ self.MonacoEnvironment = {
}
const languageMap = {
'c': 'objective-c', // Somehow the repo doesn't have C language
'c-plus-plus': 'cpp',
'c-sharp': 'csharp',
'haskell': null,
'html': 'html',
'java': 'java',
'javascript': 'javascript',
'jinja2': null,
'jsx': 'javascript',
'markdown': 'markdown',
'perl': 'perl',
'php': 'php',
'postgresql': 'sql',
'python2': 'python',
'python3': 'python',
'raku': null,
'rust': 'rust',
'sh': 'shell',
'sql': 'sql',
'sqlite': 'sql',
'typescript': 'typescript',
'typescript-jsx': 'typescript',
c: 'objective-c', // Somehow the repo doesn't have C language
cpp: 'cpp',
csharp: 'csharp',
haskell: null,
html: 'html',
java: 'java',
javascript: 'javascript',
jinja2: null,
jsx: 'javascript',
markdown: 'markdown',
perl: 'perl',
php: 'php',
plaintext: null,
postgresql: 'sql',
python2: 'python',
python3: 'python',
raku: null,
rust: 'rust',
sh: 'shell',
sql: 'sql',
sqlite: 'sql',
typescript: 'typescript',
tsx: 'typescript',
}
class MonacoEditor {
......
UPDATE languages SET identifier = CASE identifier
WHEN 'plaintext' THEN 'plain-text'
WHEN 'cpp' THEN 'c-plus-plus'
WHEN 'csharp' THEN 'c-sharp'
WHEN 'python' THEN 'python3'
WHEN 'tsx' THEN 'typescript-jsx'
ELSE identifier
END;
UPDATE languages SET identifier = CASE identifier
WHEN 'plain-text' THEN 'plaintext'
WHEN 'c-plus-plus' THEN 'cpp'
WHEN 'c-sharp' THEN 'csharp'
WHEN 'python3' THEN 'python'
WHEN 'typescript-jsx' THEN 'tsx'
ELSE identifier
END;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment