var compile = doc.getLanguage().getDefaultCompilerToLanguage("html");
// This method doesn't exist yet, but turning a path into a URL involves more
$preview.html(compile(doc.getText()));
// than adding a prefix, so there should be a utility function somewhere.
};
return doc.file.getUrlForFullPath();
},
$(doc).on("change", sync);
open: function (url) {
sync();
// url would be something like "http://localhost:12345/markdown.html"
$.get(url, function (contents) {
// ... extract the <body> ...
// Add preview frame to Brackets
// Fill and show the preview frame in Brackets
$preview.appendTo(...);
$preview.html(contents).appendTo(...);
});
},
},
close: function () {
close: function () {
// Close preview frame
// Remove the preview frame
$preview.remove();
$preview.remove();
$(doc).off("change", sync);
sync = null;
}
}
});
});
// Mark this client as compatible with every language that has an HTML compiler
This client would only support "reloading" by calling client.open again. For a more elaborate updating behavior, clients would need to declare support for such operations in a structured manner.
function considerLanguage(language) {
if (language.getDefaultCompilerToLanguage("html")) {
// Indirectly define MIME types via a language to make synchronization unnecessary
// when adding MIME types to the language
client.addLanguage(language);
}
}
// Consider new or modified languages
$(LanguageManager).on("languageAdded languageModified", function (e, language) {
In this example, the client would handle updating the document itself. Behavior like this should however be triggered by Brackets in a central place to be extensible and possibly adjustable by the user. This requires the client definition to declare support for such operations in a structured manner.