This repository was archived by the owner on Feb 4, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
src/main/java/org/scijava/jupyter/kernel/evaluator Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ private void addLanguage(String languageName) {
132
132
String firstLanguage = this .scriptEngines .keySet ().iterator ().next ();
133
133
bindings = this .scriptEngines .get (firstLanguage ).getBindings (ScriptContext .ENGINE_SCOPE );
134
134
}
135
-
135
+
136
136
log .info ("Script Language for '" + languageName + "' found." );
137
137
ScriptLanguage scriptLanguage = scriptService .getLanguageByName (languageName );
138
138
this .scriptLanguages .put (languageName , scriptLanguage );
@@ -154,10 +154,20 @@ private void addLanguage(String languageName) {
154
154
private String setLanguage (String code ) {
155
155
156
156
if (code .startsWith ("#!" )) {
157
- this .languageName = code .substring (2 , code .indexOf ("\n " )).trim ();
158
157
159
- // Return the code string without the first line
160
- code = code .substring (code .indexOf (System .getProperty ("line.separator" )) + 1 );
158
+ // If code is composed of multiple lines
159
+ if (code .split ("\n " ).length > 1 ) {
160
+ this .languageName = code .substring (2 , code .indexOf ("\n " )).trim ();
161
+
162
+ // Return the code string without the first line
163
+ code = code .substring (code .indexOf (System .getProperty ("line.separator" )) + 1 );
164
+ } // If only one line
165
+ else {
166
+ this .languageName = code .substring (2 ).trim ();
167
+
168
+ code = "" ;
169
+ }
170
+
161
171
}
162
172
163
173
this .addLanguage (this .languageName );
You can’t perform that action at this time.
0 commit comments