Skip to content

Commit 3602f83

Browse files
Enable syntax highlighting for URDFs (#26)
1 parent 9b51fbd commit 3602f83

File tree

3 files changed

+338
-3
lines changed

3 files changed

+338
-3
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"dependencies": {
5757
"@jupyterlab/application": "^3.4.0",
5858
"@jupyterlab/apputils": "^3.4.0",
59+
"@jupyterlab/codemirror": "^3.4.8",
5960
"@jupyterlab/docregistry": "^3.4.0",
6061
"@jupyterlab/filebrowser": "^3.4.0",
6162
"@jupyterlab/launcher": "^3.4.0",
@@ -66,10 +67,11 @@
6667
"@lumino/messaging": "^1.10.0",
6768
"@lumino/signaling": "^1.10.0",
6869
"@lumino/widgets": "^1.30.0",
69-
"amphion": "npm:@robostack/amphion@^0.1.25",
70-
"roslib": "npm:@robostack/roslib@^1.1.1",
70+
"@types/codemirror": "^5.60.5",
7171
"@types/dat.gui": "^0.7.7",
72-
"dat.gui": "^0.7.9"
72+
"amphion": "npm:@robostack/amphion@^0.1.25",
73+
"dat.gui": "^0.7.9",
74+
"roslib": "npm:@robostack/roslib@^1.1.1"
7375
},
7476
"devDependencies": {
7577
"@babel/core": "^7.0.0",

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import { UrdfWidgetFactory } from './factory';
2626

2727
import { urdf_icon } from './icons';
2828

29+
// For syntax highlighting
30+
import { Mode } from '@jupyterlab/codemirror';
31+
2932
// Name of the factory that creates the URDF widgets
3033
const FACTORY = 'URDF Widget Factory';
3134

@@ -90,6 +93,14 @@ const extension: JupyterFrontEndPlugin<void> = {
9093
tracker.add(widget);
9194
});
9295

96+
// Syntax highlighting
97+
Mode.getModeInfo().push({
98+
name: 'URDF',
99+
mime: 'text/xml',
100+
mode: 'xml',
101+
ext: ['urdf', 'xacro']
102+
});
103+
93104
// Register widget and model factories
94105
app.docRegistry.addWidgetFactory(widgetFactory);
95106

@@ -101,6 +112,7 @@ const extension: JupyterFrontEndPlugin<void> = {
101112
iconClass: 'jp-URDFIcon',
102113
fileFormat: 'text',
103114
contentType: 'file',
115+
mimeTypes: ['application/xml', 'text/xml'],
104116
icon: urdf_icon
105117
});
106118

0 commit comments

Comments
 (0)