Get Raw text output from Javascript macro

127 views
Skip to first unread message

Mohammad

unread,
Mar 1, 2019, 5:05:43 AM3/1/19
to TiddlyWiki
In TW macro the below pragma 

\rules only


prevents the macro output from wikification! Is there such a practice for Tiddlywiki JavaScript macro?

I mean how prevent TW from wikification of a JS macro output or how get the raw text as output?


--Mohammad

Jeremy Ruston

unread,
Mar 2, 2019, 11:13:45 AM3/2/19
to tiddl...@googlegroups.com
Hi Mohammad
To render the plain output of a JS macro you can do this:

<pre><$text text=<<dumpvariables>>/></pre>

If you need the output in a variable you’ll need to use the wikify widget:

<$wikify name="output" text="""<pre><$text text=<<dumpvariables>>/></pre>""">
<$text text={{{ [<output>split[|]join[||]] }}} />
</$wikify>

Best wishes

Jeremy



--Mohammad

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1bf3a347-d63a-451f-9b78-028e67963637%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Mar 2, 2019, 11:26:22 AM3/2/19
to TiddlyWiki
Hi Jeremy
Many thanks for your reply!
I will make some experiment and will return to you!

Cheers
Mohammad

Mohammad

unread,
Mar 2, 2019, 11:39:13 AM3/2/19
to TiddlyWiki
Hi Jeremy
Thanks a million, it works!

Just one further question, if I have to call my macro using $macrocall widget, how can I do this?
Example when I have to pass other variables as input parameter to my macro!

--Mohammad


On Saturday, March 2, 2019 at 7:43:45 PM UTC+3:30, Jeremy Ruston wrote:

Jeremy Ruston

unread,
Mar 2, 2019, 12:20:45 PM3/2/19
to tiddl...@googlegroups.com
Hi Mohammad


On 2 Mar 2019, at 16:39, Mohammad <mohammad...@gmail.com> wrote:


Just one further question, if I have to call my macro using $macrocall widget, how can I do this?
Example when I have to pass other variables as input parameter to my macro!

Try something like this:

<$wikify name="output" text="""<$macrocall $name="datauri" title="$:/SiteTitle"/>""">
<$text text={{{ [<output>split[TiddlyWiki]join[WikiTiddly]] }}} />
</$wikify>

Best wishes

Jeremy

Mohammad

unread,
Mar 2, 2019, 1:28:51 PM3/2/19
to TiddlyWiki
Thanks Jeremy!
 I think I did not correctly asked the second questions: In the below example

<$wikify name="output" text="""<pre><$text text=<<dumpvariables>>/></pre>""">
<$text text={{{ [<output>split[|]join[||]] }}} />
</$wikify>

How can I call macro using $macrocall? One use-case is where the input parameters are variable themselves.
Still I need the result without wikifivation?

--Mohammad

Mohammad

unread,
Mar 2, 2019, 1:49:36 PM3/2/19
to TiddlyWiki
Jeremy,
 This may not seems the correct solution, but If I warp the <pre><$text text=<<dumpvariables>>/></pre> in another macro, then I can pass vars as $(var)$ and uses the <<mycar p1 p2 3p3>> format!

Please advise!

--Mohammad

Jeremy Ruston

unread,
Mar 2, 2019, 3:23:32 PM3/2/19
to tiddl...@googlegroups.com
Hi Mohammad


 I think I did not correctly asked the second questions: In the below example

<$wikify name="output" text="""<pre><$text text=<<dumpvariables>>/></pre>""">
<$text text={{{ [<output>split[|]join[||]] }}} />
</$wikify>

How can I call macro using $macrocall? One use-case is where the input parameters are variable themselves.
Still I need the result without wikifivation?

I’m afraid that goes back to something we’ve discussed before: there isn’t a way to get the results of a macrocall widget into a variable without wikification:


Best wishes

Jeremy.



--Mohammad




On Saturday, March 2, 2019 at 8:50:45 PM UTC+3:30, Jeremy Ruston wrote:
Hi Mohammad

On 2 Mar 2019, at 16:39, Mohammad <mohammad...@gmail.com> wrote:


Just one further question, if I have to call my macro using $macrocall widget, how can I do this?
Example when I have to pass other variables as input parameter to my macro!

Try something like this:

<$wikify name="output" text="""<$macrocall $name="datauri" title="$:/SiteTitle"/>""">
<$text text={{{ [<output>split[TiddlyWiki]join[WikiTiddly]] }}} />
</$wikify>

Best wishes

Jeremy

-- 
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Mohammad

unread,
Mar 2, 2019, 3:33:34 PM3/2/19
to TiddlyWiki
Hi Jeremy,

That's right! 

By the way as you advised in your first post and wrapping the my macro into another macro I could get the non-wikified e.g. the raw text into 
a variable. I think the magic is your clever solution in the below script "<pre><$text text=<<dumpvariables>>/></pre>".


\define mac()
<pre><$text text=<<regexpsub sourceText:"""$(source)$""" searchValue:$(searchValue)$ replaceValue:$(replaceValue)$ caseSensitive:$(caseSensitive)$>>  /></pre>
\end


\define another-macro(.......)
<$wikify name="result" text=<<mac>> >
<$text text=<<result>>/>
...
\end




I use this in my new search-n-replace code (I call it SNR2) to call a JS macro and
do a search-n-replace.

I will upload the solution shortly.

Many thanks for your time and your clever solution.

Cheers
Mohammad

Mohammad

unread,
Mar 2, 2019, 3:54:48 PM3/2/19
to TiddlyWiki
Hi Jeremy
 See your solution in action. SNR2



--Mohammad

Jeremy Ruston

unread,
Mar 3, 2019, 7:45:33 AM3/3/19
to tiddl...@googlegroups.com
Hi Mohammad


On 2 Mar 2019, at 20:23, Jeremy Ruston <jeremy...@gmail.com> wrote:

I’m afraid that goes back to something we’ve discussed before: there isn’t a way to get the results of a macrocall widget into a variable without wikification:

Of course, I gave up too early. Here’s a method that works in the cases I’ve tried:

<$wikify name="output" text="""<$macrocall $type="text/plain" $name="dumpvariables"/>""">
<$text text=<<output>>/>
</$wikify>

The trick is to use the “type” attribute of the macrocall widget. It causes it to interpret the text as plain text, rather than wikitext. However, if you try <$macrocall $type="text/plain" $name="dumpvariables"/> on it’s own you’ll see that it puts the text in a plain text block (like triple backticks). The wikify widget lets us extract the plain text from that output.

Best wishes

Jeremy.

Mohammad

unread,
Mar 3, 2019, 8:05:28 AM3/3/19
to TiddlyWiki
Hi Jeremy
 This is absolutely much better than the previous one I used. It works for me.

Thank you Jeremy

Cheers
Mohammad
Reply all
Reply to author
Forward
0 new messages