Skip to content

Commit

Permalink
export with standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Jan 25, 2025
1 parent fa175c6 commit 16fdcbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ exportButton.addEventListener('click', () => {
exportCloseButton.focus();
});

let stdSource = '';
fetch('/src/std.js').then(async (response) => {
stdSource = await response.text();
});

// Return the lines of a panel view.
function getDocumentText(view) {
const doc = view.viewState.state.doc;
Expand All @@ -25,7 +30,7 @@ function getDocumentText(view) {

export function getFlokLink() {
const prettyDate = getPrettyDate();
const prefix = `// "nudel ${prettyDate}" @by pastagang\n//\n`;
const prefix = `// "nudel ${prettyDate}" @by pastagang\n//\n${stdSource}`;

const panels = [];
const targets = [];
Expand Down Expand Up @@ -63,7 +68,7 @@ export function downloadAsFile(txt, { fileName = `nudel-export-${getPrettyDate()

export function getCode(filter) {
const prettyDate = getPrettyDate();
const headline = `// "nudel ${prettyDate}" @by pastagang`;
const headline = `// "nudel ${prettyDate}" @by pastagang\n${stdSource}`;
let documents = session.getDocuments();
if (filter) {
documents = documents.filter(filter);
Expand Down
10 changes: 6 additions & 4 deletions src/std.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//=== NUDEL STANDARD LIBRARY ===//
function spag(name) {
return `https://spag.cc/${name}`;
return 'https://spag.cc/' + name;
}

function listToArray(stringList) {
Expand All @@ -13,7 +14,7 @@ function listToArray(stringList) {
.filter((v) => v);
}

function spagda(nameList) {
async function spagda(nameList) {
const names = listToArray(nameList);
if (names.length === 0) {
return;
Expand All @@ -25,7 +26,7 @@ function spagda(nameList) {
samples(map);
}

function speechda(
async function speechda(
wordList = '',
// default to PC music
locale = 'en-GB',
Expand All @@ -51,9 +52,10 @@ function speechda(
if (words.length === 0) {
return;
}
samples(`shabda/speech/${locale}/${gender}:${words.join(',')}`);
samples('shabda/speech/' + locale + '/' + gender + ':' + words.join(','));
}

window.speechda = speechda;
window.spagda = spagda;
window.spag = spag;
//=== END OF NUDEL STANDARD LIBRARY ===//

0 comments on commit 16fdcbc

Please sign in to comment.