Commit 0d47cf2b authored by Benjamin Fischer's avatar Benjamin Fischer

extension/codeeditor: added preview dir parsing from content

parent e7c513f5
......@@ -88,6 +88,7 @@ define(["jquery", "emitter", "vispa/utils"], function($, Emitter, Utils) {
self.view.state.set("writable", self.view.state.get("writable") && res.writable, 1);
self.view.state.set("path", path);
self.parseShebang(res.content);
self.parsePreview(res.content);
self.mtime = res.mtime;
self.editor.setContent(res.content);
if (!reset)
......@@ -157,6 +158,18 @@ define(["jquery", "emitter", "vispa/utils"], function($, Emitter, Utils) {
this.view.state.set("command", command);
},
parsePreview: function(content) {
var preview = content.match(/(?:preview|plot)s?_?(?:path|dir|prefix)\s*[:=]*\s*(["']+)(.+?)\1[^\n"']*\bVISPA(?:[ -_]*codeeditor)?(?:[ -_]*preview)?\b[^\n"']*$/im);
if (!preview) return;
preview = preview[2];
if (!preview.startsWith("/")) {
var parts = this.view.state.get("path").split("/");
parts[parts.length - 1] = preview;
preview = parts.join("/");
}
this.view.state.set("previewPath", preview);
},
setupAutoSave: function() {
var self = this;
......
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