Skip to content

Commit

Permalink
mp3 + Better linked files extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonLukas committed Oct 17, 2022
1 parent d85ed2f commit ce6711a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
20 changes: 13 additions & 7 deletions main.js

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ export default class Kindle extends Plugin {
Inhalt += '\n<p><img class="intern" src="uploads/' + file.name + '"></p>' + '\n\n';
}

if (file.extension == "mp3") {
let data = await this.app.vault.readBinary(file);
let base64 = Buffer.from(data).toString('base64');
imagename.push(file.name);
imagelist.push(base64);
Inhalt += '\n<p><audio class="intern" type="audio/mpeg" src="uploads/' + file.name + '" controls="controls"/></p>' + '\n\n';
}

if (file.extension == 'md') {
let links2: Array < string > = [];
let data = await this.app.vault.cachedRead(file);
Expand All @@ -262,17 +270,16 @@ export default class Kindle extends Plugin {
}


let ankers = LinkFile.reference.link.split('#');
console.log(ankers);
let anker = ankers[ankers.length - 1];
let heading = '<h3><i>' + LinkFile.reference.displayText + '</i></h3>\n\n';
let anker = LinkFile.reference.link.split('#');
anker = anker[anker.length - 1];
let heading = '<h3><i>' + LinkFile.reference.displayText + '</i></h3>\n';

if (ankers.length > 1) {
if (anker != undefined) {
if (anker.contains("^")) {
console.log(anker);
let ankercaret = text.indexOf(anker);
text = text.substring(0, ankercaret);
text = text.substring(text.lastIndexOf("\n\n"));
text = text.substring(text.lastIndexOf("\n"));
heading = '';
} else {
let pos = text.indexOf(anker);
Expand Down

0 comments on commit ce6711a

Please sign in to comment.