tag:support.markedapp.com,2011-09-11:/discussions/problems/161991-manual-refresh-needed-when-using-mathjax-from-scriptMarked: Discussion 2023-03-30T14:48:13Ztag:support.markedapp.com,2011-09-11:Comment/490580902021-02-26T09:33:52Z2021-02-26T09:33:52Z*manual* refresh needed when using mathjax from script<div><p>...the screenshots here...</p></div>jaromir.benestag:support.markedapp.com,2011-09-11:Comment/490580902021-02-26T11:18:57Z2021-02-26T11:18:57Z*manual* refresh needed when using mathjax from script<div><p>Unfortunately this is expected behavior. The last major update to Marked<br>
switched its preview to use DOM injection rather than a full reload when<br>
updating, and that doesn't re-trigger MathJax's rendering. The built-in<br>
MathJax compensates for this by calling the MathJax typeset method on<br>
every update, but there's no hook currently available for refreshing<br>
external scripts the same way. (Though if I could find an elegant way to<br>
do that, I'd take it under consideration.)</p>
<p><code>x-marked://refresh</code> really should work the same as ⌘R, though, and you could have an x-success param that returned focus to your editor. If<br>
that's a workable solution for you, I'm happy to look into why that<br>
wouldn't be performing a full refresh. Might have broken something over<br>
the last few updates.</p>
<p>-Brett</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/490580902021-02-26T12:19:28Z2021-02-26T12:19:28Z*manual* refresh needed when using mathjax from script<div><p>Many thanks, Brett, for your prompt reply!</p>
<p>I double checked the behavior of x-marked://refresh and it, indeed, does not render the math - however, x-success does trigger the url. Worse still, if I run it on an existing, unchanged, correctly rendered preview, it actually reverts all math to its underlying source code...</p>
<p>And yes, I'd be more than grateful to you for looking into this. Getting this fixed would save me a lot of pain switching back and forth :)</p>
<p>Many thanks for all your work on Marked2.</p>
<p>Best<br>
Jaromir</p></div>jaromir.benestag:support.markedapp.com,2011-09-11:Comment/490580902021-02-26T12:50:43Z2021-02-26T12:50:43Z*manual* refresh needed when using mathjax from script<div><p>I'll try to have the refresh handler working for the next update.</p>
<p>I also took some time to think about it and it makes sense to me to have<br>
a queue available through the JS API that lets you add functions to run<br>
on update. Something like <code>Marked.queue.push(function(){ MathJax.Typeset(...) }</code>. Then you could just add a couple lines to any<br>
script and have it refresh when Marked does without requiring a full<br>
reload. Don't know if you're a javascript person at all, but I'd be open<br>
to ideas on that front if you are. Even if you're not, I think I could<br>
make it easy enough that anyone could implement with some handy<br>
instructions...</p>
<p>-Brett</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/490580902021-02-26T14:24:32Z2021-02-26T14:24:32Z*manual* refresh needed when using mathjax from script<div><p>Thanks. I'm more of a matlab/python/julia person with just the bare minimum<br>
skills in js so I guess am of no help to you on this :) But a queue of<br>
user functions triggered on update looks like a simple elegant solution.</p>
<p>Look forward,<br>
Jaromir</p></div>jaromir.benestag:support.markedapp.com,2011-09-11:Comment/490580902023-03-29T23:11:28Z2023-03-29T23:11:30Z*manual* refresh needed when using mathjax from script<div><p>Would love to bump this up. Something like a <code>Marked.onupdate.push(function() { /* do the things */ });</code> would be very useful for handling Mermaid diagrams and also for updates to slides using marp. Both of those do Bad Things after an update and I have to cmd-tab to Marked and cmd-r after each save, which is a bummer. If something like this has already been added, please do share! I didn't find anything in the knowledgebase or the docs.</p></div>Patrick Walshtag:support.markedapp.com,2011-09-11:Comment/490580902023-03-29T23:50:15Z2023-03-29T23:50:15Z*manual* refresh needed when using mathjax from script<div><p><a href="https://marked2app.com/help/Embedding_Scripts.html">https://marked2app.com/help/Embedding_Scripts.html</a></p>
<ul>
<li>Brett</li>
</ul></div>Bretttag:support.markedapp.com,2011-09-11:Comment/490580902023-03-30T14:48:10Z2023-03-30T14:48:13Z*manual* refresh needed when using mathjax from script<div><p>Sorry I failed to find that even after searching via google and site! Great to see!</p></div>Patrick Walsh