Skip to content

Get current tiddler text in JS macro #6720

Answered by danfarrow
danfarrow asked this question in Q&A
Discussion options

You must be logged in to vote

I have now got this working, building on the previous answers - thanks again!

Inside the macro, this gets the text of the current tiddler:

const currentTiddlerName = this.variables.currentTiddler.value;
const currentTiddler = this.wiki.getTiddler(currentTiddlerName);
const text = currentTiddler.fields["text"];

I extract the table wikitext using a regular expression (only supports a single table currently):

const regex = /\|[^]*\|/g;
return regex.exec(text)[0];

Replies: 5 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@danfarrow
Comment options

Comment options

You must be logged in to vote
1 reply
@danfarrow
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by danfarrow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants