Skip to content

Commit dae9342

Browse files
committed
Fix transform output language detection; expand MIME type mappings
Use mimeType instead of the non-existent id field on transform mediaTypes objects when passing the language to CodeViewer. Add primary language entries and MIME type / file extension aliases for all languages registered in hljs (xml, html, css, typescript, sql, sparql, jq, markdown, graphql, ruby, go, rust, cpp, c, kotlin, swift, scala, r, lua, perl, php, wasm, xquery, latex, protobuf). html is kept distinct from xml with highlight: 'xml', matching the jsonld/json pattern.
1 parent 297561a commit dae9342

2 files changed

Lines changed: 75 additions & 2 deletions

File tree

src/components/bblock/ExampleTransformResults.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<code-viewer
6666
v-if="!outputStatus.loading && !outputStatus.error && outputStatus.contents"
6767
:code="outputStatus.contents"
68-
:language="selectedOutput.transform.outputs.mediaTypes[0].id"
68+
:language="selectedOutput.transform.outputs.mediaTypes[0].mimeType"
6969
>
7070
</code-viewer>
7171
<v-alert v-if="outputStatus.error" type="error">Error loading transform output from {{

src/models/mime-types.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,91 @@ const knownLanguages = {
77
'java': { id: 'java', order: 6, label: 'Java' },
88
'python': { id: 'python', order: 7, label: 'Python' },
99
'javascript': { id: 'javascript', order: 8, label: 'Javascript' },
10-
'bash': {id: 'bash', order: 9, label: 'Bash'},
10+
'bash': { id: 'bash', order: 9, label: 'Bash' },
1111
'geojson': { id: 'geojson', order: 2, label: 'GeoJSON', highlight: 'json' },
12+
'xml': { id: 'xml', order: 10, label: 'XML' },
13+
'html': { id: 'html', order: 11, label: 'HTML', highlight: 'xml' },
14+
'css': { id: 'css', order: 12, label: 'CSS' },
15+
'typescript': { id: 'typescript', order: 13, label: 'TypeScript' },
16+
'sql': { id: 'sql', order: 14, label: 'SQL' },
17+
'sparql': { id: 'sparql', order: 15, label: 'SPARQL' },
18+
'jq': { id: 'jq', order: 16, label: 'jq' },
19+
'markdown': { id: 'markdown', order: 17, label: 'Markdown' },
20+
'graphql': { id: 'graphql', order: 18, label: 'GraphQL' },
21+
'ruby': { id: 'ruby', order: 19, label: 'Ruby' },
22+
'go': { id: 'go', order: 20, label: 'Go' },
23+
'rust': { id: 'rust', order: 21, label: 'Rust' },
24+
'cpp': { id: 'cpp', order: 22, label: 'C++' },
25+
'c': { id: 'c', order: 23, label: 'C' },
26+
'kotlin': { id: 'kotlin', order: 24, label: 'Kotlin' },
27+
'swift': { id: 'swift', order: 25, label: 'Swift' },
28+
'scala': { id: 'scala', order: 26, label: 'Scala' },
29+
'r': { id: 'r', order: 27, label: 'R' },
30+
'lua': { id: 'lua', order: 28, label: 'Lua' },
31+
'perl': { id: 'perl', order: 29, label: 'Perl' },
32+
'php': { id: 'php', order: 30, label: 'PHP' },
33+
'wasm': { id: 'wasm', order: 31, label: 'WebAssembly' },
34+
'xquery': { id: 'xquery', order: 32, label: 'XQuery' },
35+
'latex': { id: 'latex', order: 33, label: 'LaTeX' },
36+
'protobuf': { id: 'protobuf', order: 34, label: 'Protocol Buffers' },
1237

38+
// file extension aliases
1339
'ttl': 'turtle',
1440
'json-ld': 'jsonld',
1541
'yml': 'yaml',
1642
'txt': 'plaintext',
1743
'js': 'javascript',
44+
'ts': 'typescript',
45+
'md': 'markdown',
46+
'rb': 'ruby',
47+
'rs': 'rust',
48+
'kt': 'kotlin',
1849
'rdf/turtle': 'turtle',
50+
'htm': 'html',
51+
'pgsql': 'sql',
52+
'postgres': 'sql',
53+
54+
// MIME type aliases
1955
'application/json': 'json',
2056
'application/geo+json': 'geojson',
2157
'application/yaml': 'yaml',
58+
'application/xml': 'xml',
59+
'application/javascript': 'javascript',
60+
'application/typescript': 'typescript',
61+
'application/sql': 'sql',
62+
'application/sparql-query': 'sparql',
63+
'application/sparql-update': 'sparql',
64+
'application/graphql': 'graphql',
65+
'application/wasm': 'wasm',
66+
'application/xquery': 'xquery',
67+
'application/x-latex': 'latex',
68+
'application/protobuf': 'protobuf',
69+
'application/x-python': 'python',
70+
'application/x-httpd-php': 'php',
71+
'text/xml': 'xml',
72+
'text/html': 'html',
73+
'text/css': 'css',
74+
'text/javascript': 'javascript',
75+
'text/typescript': 'typescript',
76+
'text/markdown': 'markdown',
77+
'text/x-sql': 'sql',
78+
'text/x-python': 'python',
79+
'text/x-ruby': 'ruby',
80+
'text/x-go': 'go',
81+
'text/x-rust': 'rust',
82+
'text/x-c++src': 'cpp',
83+
'text/x-csrc': 'c',
84+
'text/x-java': 'java',
85+
'text/x-java-source': 'java',
86+
'text/x-kotlin': 'kotlin',
87+
'text/x-swift': 'swift',
88+
'text/x-scala': 'scala',
89+
'text/x-r': 'r',
90+
'text/x-lua': 'lua',
91+
'text/x-perl': 'perl',
92+
'text/x-php': 'php',
93+
'text/x-latex': 'latex',
94+
'text/turtle': 'turtle',
2295
'shell': 'bash',
2396
'sh': 'bash',
2497
};

0 commit comments

Comments
 (0)