Skip to content

Commit

Permalink
Extract active melody when saving EsAC data as HTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Sep 7, 2024
1 parent cbc9814 commit 3a40542
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions _includes/vhv-scripts/buffer/downloadEditorContentsInHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,44 @@ function downloadEditorContentsInHtml() {
var filebase = getFilenameBase();
var ext = "html";
var filename = filebase + "." + ext;
var text = getTextFromEditor();

var humdrum = dataIsHumdrum(text);
if (humdrum && GLOBALFILTER) {
if (text.charAt[text.length-1] !== "\n") {
text += "\n";
}
text += "!!!filter: " + GLOBALFILTER + "\n";
var text = "";
if (EditorMode === "esac") {
text = getCurrentEsacMelody();
text = text.replace(/\r/g, '');
} else {
text = getTextFromEditor();
}
if (!text.endsWith('\n')) {
text += '\n';
}
var humdrum = dataIsHumdrum(text);

var output = '<html>\n';
output += '<head>\n';
output += '<title>My Score</title>\n';
output += '<script src="https://plugin.humdrum.org/scripts/humdrum-notation-plugin-worker.js">\n';
output += '</sc' + 'ript>\n';
output += '</head>\n';
output += '<body>\n';
output += '<script>\n';
output += ' displayHumdrum({\n';
output += ' source: "my-score",\n';
output += ' autoResize: "true",\n';
output += `</sc` + `ript>\n`;
output += `</head>\n`;
output += `<body>\n`;
output += `<script>\n`;
output += ` displayHumdrum({\n`;
output += ` source: "my-score",\n`;
output += ` autoResize: "true",\n`;
if (BREAKS) {
output += ` breaks: "encoded",\n`;
}
if ((EditorMode === "humdrum") && GLOBALFILTER) {
let filter = GLOBALFILTER.replace(/"/g, '\\"');
output += ` filter: "${filter}",\n`;
}
output += ' header: "true"\n';
output += ' });\n';
output += '<!-- See https://plugin.humdrum.org/options/#list for more display options -->\n';
output += '</script>\n';
output += '\n';
output += '<script type="text/x-humdrum" id="my-score">\n';
output += text;

output += '</script>\n';
output += '\n';
output += '</body>\n';
Expand Down

0 comments on commit 3a40542

Please sign in to comment.