This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
/* | |
Requires: Templater | |
This template will create new files containing the content between | |
each thematic break "---" in the current file (ignoring the metadata) | |
and add links to the new files in the current file. | |
If you don't like the result just undo a few times | |
and delete the newly created files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
// cleaner version can be made using moment.js | |
// format date to YYYY-MM-DD (date -> string) | |
function formatDate(date) { | |
// https://stackoverflow.com/questions/23593052/format-javascript-date-as-yyyy-mm-dd | |
var d = new Date(date), | |
month = '' + (d.getMonth() + 1), | |
day = '' + d.getDate(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Word Count from Tagged Pages | |
## Search Tag | |
tagToSearchFor:: anotherTag | |
^ This inline metadata field is used as the tag that dataview searches the vault for. Write the name of the tag without the hash in front or `null` for all pages in your vault. You can use MetaEdit to change search term in preview mode. Search by other fields soon to come! | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```dataviewjs | |
let text = app.workspace.activeLeaf.view.file.unsafeCachedData; | |
// thanks to https://www.tutorialspoint.com/how-to-count-a-number-of-words-in-given-string-in-javascript | |
text = text.replace(/(^\\s\*)|(\\s\*$)/gi,""); // remove the start and end spaces of the given string | |
text = text.replace(/\[ \]{2,}/gi," "); // reduce multiple spaces to a single space | |
text = text.replace(/\\n /,"\\n"); // exclude a new line with a start spacing | |
// thanks to Luke Leppan and the Better Word Count plugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is templater template to copy and paste in an Obsidian .md file not JS, just nice for looking at the formatting << delete me! | |
<%* | |
// define function to replace timestamps in file | |
function replaceTimestamp () { | |
const regexHHMM = /(YT=\d\d:[0-5]\d)/g; | |
// change "YT=" if you want a different search term. currently videos cannot be longer than 99m59s | |
var content = tp.file.content; // *content of file* | |
var matches = content.match(regexHHMM); // *find all regex matches in file* | |
const matchesLength = matches.length; // *length of array containing all matches* |