From fb4e4b3e13f7b4471704e5f4c1b69f5ce4aba734 Mon Sep 17 00:00:00 2001 From: LUCASTUCIOUS Date: Mon, 3 Apr 2023 23:14:39 +0200 Subject: [PATCH] vault backup: 2023-04-03 23:14:38 --- .obsidian/plugins/longform/data.json | 4 +-- .obsidian/plugins/longform/sessions.json | 2 +- .obsidian/vault-stats.json | 2 +- Projets/Scripts/replaceLinks.js | 37 +++++++++++++++++++----- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.obsidian/plugins/longform/data.json b/.obsidian/plugins/longform/data.json index 0ed7392..0e547e3 100644 --- a/.obsidian/plugins/longform/data.json +++ b/.obsidian/plugins/longform/data.json @@ -66,8 +66,8 @@ { "id": "Projets/Scripts/replaceLinks.js", "optionValues": { - "removeH1": true, - "removeFrontmatter": true + "removeH1": false, + "removeFrontmatter": false } }, { diff --git a/.obsidian/plugins/longform/sessions.json b/.obsidian/plugins/longform/sessions.json index e94a55d..aa7c6af 100644 --- a/.obsidian/plugins/longform/sessions.json +++ b/.obsidian/plugins/longform/sessions.json @@ -1 +1 @@ -[{"start":"2023-04-03T20:19:46.909Z","total":0,"drafts":{"Projets/Absolue Nécessitée/Index.md":{"total":0,"scenes":{"Chapitre 1 - Montée en puissance":0,"Diner chez Althéa":0,"Assassinat raté":0}}}},{"start":"2023-04-03T20:18:34.855Z","total":0,"drafts":{"Projets/Absolue Nécessitée/Index.md":{"total":0,"scenes":{}}}}] \ No newline at end of file +[{"start":"2023-04-03T20:57:35.312Z","total":0,"drafts":{"Projets/Absolue Nécessitée/Index.md":{"total":0,"scenes":{"Chapitre 1 - Montée en puissance":0,"Diner chez Althéa":0,"Assassinat raté":0}}}}] \ No newline at end of file diff --git a/.obsidian/vault-stats.json b/.obsidian/vault-stats.json index 9de7250..06cfff5 100644 --- a/.obsidian/vault-stats.json +++ b/.obsidian/vault-stats.json @@ -1 +1 @@ -{"history":{"2023-03-01":{"words":845,"characters":1255,"sentences":0,"files":123,"totalWords":29296,"totalCharacters":231518,"totalSentences":821},"2023-03-02":{"words":39,"characters":281,"sentences":0,"files":123,"totalWords":29296,"totalCharacters":231518,"totalSentences":821},"2023-03-03":{"words":644,"characters":3897,"sentences":23,"files":123,"totalWords":29940,"totalCharacters":233149,"totalSentences":844},"2023-03-05":{"words":0,"characters":0,"sentences":0,"files":0,"totalWords":29940,"totalCharacters":233149,"totalSentences":844},"2023-03-06":{"words":0,"characters":0,"sentences":0,"files":0,"totalWords":29940,"totalCharacters":233149,"totalSentences":844},"2023-03-07":{"words":16,"characters":103,"sentences":0,"files":123,"totalWords":29956,"totalCharacters":233253,"totalSentences":844},"2023-03-08":{"words":6,"characters":47,"sentences":1,"files":123,"totalWords":29964,"totalCharacters":233304,"totalSentences":845},"2023-03-10":{"words":15,"characters":102,"sentences":0,"files":124,"totalWords":30010,"totalCharacters":233650,"totalSentences":846},"2023-03-14":{"words":68,"characters":445,"sentences":4,"files":126,"totalWords":30274,"totalCharacters":235667,"totalSentences":857},"2023-03-15":{"words":585,"characters":3851,"sentences":9,"files":129,"totalWords":30998,"totalCharacters":240608,"totalSentences":868},"2023-03-16":{"words":128,"characters":820,"sentences":7,"files":131,"totalWords":31352,"totalCharacters":245878,"totalSentences":877},"2023-03-18":{"words":30,"characters":208,"sentences":0,"files":132,"totalWords":31501,"totalCharacters":247094,"totalSentences":878},"2023-03-19":{"words":0,"characters":0,"sentences":0,"files":0,"totalWords":0,"totalCharacters":0,"totalSentences":0},"2023-03-22":{"words":2568,"characters":16916,"sentences":53,"files":133,"totalWords":34073,"totalCharacters":266611,"totalSentences":932},"2023-03-24":{"words":7,"characters":50,"sentences":0,"files":133,"totalWords":34085,"totalCharacters":264035,"totalSentences":932},"2023-03-30":{"words":156,"characters":955,"sentences":9,"files":135,"totalWords":34782,"totalCharacters":265893,"totalSentences":965},"2023-03-31":{"words":129,"characters":798,"sentences":7,"files":135,"totalWords":34911,"totalCharacters":269322,"totalSentences":972},"2023-04-03":{"words":2,"characters":11,"sentences":0,"files":141,"totalWords":35205,"totalCharacters":270668,"totalSentences":988,"totalFootnotes":3,"totalCitations":0,"totalPages":117.19999999999996,"footnotes":0,"citations":0,"pages":0}},"modifiedFiles":{"Aventures/Chapitre 1 - Révolution.md":{"words":{"initial":296,"current":295},"characters":{"initial":2374,"current":2369},"sentences":{"initial":8,"current":8},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":1,"current":1}},"Projets/Absolue Nécessitée/Scenes/Diner chez Althéa.md":{"words":{"initial":0,"current":1},"characters":{"initial":1,"current":8},"sentences":{"initial":1,"current":1},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":0,"current":0}},"Projets/Absolue Nécessitée/Scenes/Assassinat raté.md":{"words":{"initial":0,"current":1},"characters":{"initial":1,"current":5},"sentences":{"initial":1,"current":1},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":0,"current":0}},"Scenes/Diner avec Althéa.md":{"words":{"initial":711,"current":642},"characters":{"initial":4765,"current":3875},"sentences":{"initial":25,"current":24},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":2.4,"current":2.1}}}} \ No newline at end of file +{"history":{"2023-03-01":{"words":845,"characters":1255,"sentences":0,"files":123,"totalWords":29296,"totalCharacters":231518,"totalSentences":821},"2023-03-02":{"words":39,"characters":281,"sentences":0,"files":123,"totalWords":29296,"totalCharacters":231518,"totalSentences":821},"2023-03-03":{"words":644,"characters":3897,"sentences":23,"files":123,"totalWords":29940,"totalCharacters":233149,"totalSentences":844},"2023-03-05":{"words":0,"characters":0,"sentences":0,"files":0,"totalWords":29940,"totalCharacters":233149,"totalSentences":844},"2023-03-06":{"words":0,"characters":0,"sentences":0,"files":0,"totalWords":29940,"totalCharacters":233149,"totalSentences":844},"2023-03-07":{"words":16,"characters":103,"sentences":0,"files":123,"totalWords":29956,"totalCharacters":233253,"totalSentences":844},"2023-03-08":{"words":6,"characters":47,"sentences":1,"files":123,"totalWords":29964,"totalCharacters":233304,"totalSentences":845},"2023-03-10":{"words":15,"characters":102,"sentences":0,"files":124,"totalWords":30010,"totalCharacters":233650,"totalSentences":846},"2023-03-14":{"words":68,"characters":445,"sentences":4,"files":126,"totalWords":30274,"totalCharacters":235667,"totalSentences":857},"2023-03-15":{"words":585,"characters":3851,"sentences":9,"files":129,"totalWords":30998,"totalCharacters":240608,"totalSentences":868},"2023-03-16":{"words":128,"characters":820,"sentences":7,"files":131,"totalWords":31352,"totalCharacters":245878,"totalSentences":877},"2023-03-18":{"words":30,"characters":208,"sentences":0,"files":132,"totalWords":31501,"totalCharacters":247094,"totalSentences":878},"2023-03-19":{"words":0,"characters":0,"sentences":0,"files":0,"totalWords":0,"totalCharacters":0,"totalSentences":0},"2023-03-22":{"words":2568,"characters":16916,"sentences":53,"files":133,"totalWords":34073,"totalCharacters":266611,"totalSentences":932},"2023-03-24":{"words":7,"characters":50,"sentences":0,"files":133,"totalWords":34085,"totalCharacters":264035,"totalSentences":932},"2023-03-30":{"words":156,"characters":955,"sentences":9,"files":135,"totalWords":34782,"totalCharacters":265893,"totalSentences":965},"2023-03-31":{"words":129,"characters":798,"sentences":7,"files":135,"totalWords":34911,"totalCharacters":269322,"totalSentences":972},"2023-04-03":{"words":2,"characters":11,"sentences":0,"files":141,"totalWords":35205,"totalCharacters":270668,"totalSentences":988,"totalFootnotes":3,"totalCitations":0,"totalPages":117.19999999999997,"footnotes":0,"citations":0,"pages":0}},"modifiedFiles":{"Aventures/Chapitre 1 - Révolution.md":{"words":{"initial":296,"current":295},"characters":{"initial":2374,"current":2369},"sentences":{"initial":8,"current":8},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":1,"current":1}},"Projets/Absolue Nécessitée/Scenes/Diner chez Althéa.md":{"words":{"initial":0,"current":1},"characters":{"initial":1,"current":8},"sentences":{"initial":1,"current":1},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":0,"current":0}},"Projets/Absolue Nécessitée/Scenes/Assassinat raté.md":{"words":{"initial":0,"current":1},"characters":{"initial":1,"current":5},"sentences":{"initial":1,"current":1},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":0,"current":0}},"Scenes/Diner avec Althéa.md":{"words":{"initial":711,"current":642},"characters":{"initial":4765,"current":3875},"sentences":{"initial":25,"current":24},"footnotes":{"initial":0,"current":0},"citations":{"initial":0,"current":0},"pages":{"initial":2.4,"current":2.1}}}} \ No newline at end of file diff --git a/Projets/Scripts/replaceLinks.js b/Projets/Scripts/replaceLinks.js index 9db2bd5..1c30fa0 100644 --- a/Projets/Scripts/replaceLinks.js +++ b/Projets/Scripts/replaceLinks.js @@ -98,21 +98,42 @@ async function replaceLinksWithContent(content, metadata, context, files, deep) return acc; } const linkedMetadata = getMetadata(linkedFile, context.app); - - let contentArray = Array.from(linkedContent); - contentArray = removeFrontmatter(contentArray, linkedMetadata.frontmatter, context.optionValues); - contentArray = removeHeaders(contentArray, linkedMetadata.headings, context.optionValues) - const cleanedContent = contentArray.filter(val => val !== null) - .join("") - .trim(); - const processedLinkedContent = await replaceLinksWithContent(cleanedContent, linkedMetadata, context, files, deep + 1) + let processedLinkedContent; + if (item.type === "embed") { + // Replace embed link with embed content + const embedProcessor = context.embedProviders.find(provider => provider.shouldProcessLink(item.link)); + if (embedProcessor) { + const embedContent = await embedProcessor.process(item.link); + if (embedContent) { + processedLinkedContent = embedContent; + } else { + processedLinkedContent = item.original; + } + } else { + processedLinkedContent = item.original; + } + } else { + // Replace regular link with linked content + let contentArray = Array.from(linkedContent); + contentArray = removeFrontmatter(contentArray, linkedMetadata.frontmatter, context.optionValues); + contentArray = removeHeaders(contentArray, linkedMetadata.headings, context.optionValues) + const cleanedContent = contentArray.filter(val => val !== null) + .join("") + .trim(); + + processedLinkedContent = await replaceLinksWithContent(cleanedContent, linkedMetadata, context, files, deep + 1); + } + return acc.replaceAll(item.original, processedLinkedContent) }, Promise.resolve(content)); } async function getLinkedContent(linkText, app, files) { const file = files.find(file => file.basename === linkText); + if (!file){ + const file = await app.vault.getAbstractFileByPath(linkText); + } return file ? [file, await app.vault.read(file)] : [];