# doJavaScript on a Markdown preview?

**URL:** <https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443>\
**Category:** Automation\
**Tags:** automation\
**Created:** [August 10, 2026, 3:07pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443 "2026-08-10T15:07:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [August 10, 2026, 3:07pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443/1 "2026-08-10T15:07:06Z")

</div>

It’s it possible to have doJavaScript inject code in a MD preview? I’m not referring to a `script` element in the MD here.

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [August 10, 2026, 3:21pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443/2 "2026-08-10T15:21:08Z")

</div>

> [@chrillek](#):
>
> It’s it possible to have doJavaScript inject code in a MD preview?

At least theoretically but specifying a script in _Settings \> Files \> Markdown_ via its item link is definitely the recommended way.

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [August 10, 2026, 3:29pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443/3 "2026-08-10T15:29:09Z")

</div>

> [@cgrunenberg](#):
>
> At least theoretically but specifying a script in _Settings \> Files \> Markdown_ via its item link is definitely the recommended way.

The difference being that is just JavaScript, equivalent to a `script` element in the MD. `doJavaScript` would be JXA-capable, i.e. it could work on records. `script` can’t.

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [August 10, 2026, 3:38pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443/4 "2026-08-10T15:38:16Z")

</div>

> [@chrillek](#):
>
> `doJavaScript` would be JXA-capable, i.e. it could work on records

It’s actually just running JavaScript in the web view (like `<script>`), it’s not JXA.

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [August 10, 2026, 3:46pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443/5 "2026-08-10T15:46:21Z")

</div>

> [@cgrunenberg](#):
>
> It’s actually just running JavaScript in the web view (like `<script>`), it’s not JXA.

Yes, I know _that_. But I could do something like that

```javascript
const app = Application("DEVONthink");
const r = app.getRecordWithUuid(...);
const tw = app.openWindowFor({record: r});
const result = app.doJavaScript(`do something here`, {in: tw});
r.plainText = r.plainText() + `\n` + result.toString();

```

Or whatever JXA permits me to do: The script runs in the context of the preview (if that works), but the `doJavaScript` runs in the context of JXA.  
Background: [Interactive task-list checkboxes in the Markdown preview — now that the MultiMarkdown dependency is gone](https://discourse.devontechnologies.com/t/interactive-task-list-checkboxes-in-the-markdown-preview-now-that-the-multimarkdown-dependency-is-gone/87429/)  
It’s trivial to have a script make the checkboxes interaktive (ie turn `disabled` off), but then… As you said, `script` is just JS, not JXA. In order to change the MD file itself, one would need JXA (or AS, for that matter).  
That’s why I was thinking of this slightly contrived approach…

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [August 10, 2026, 3:49pm UTC](https://discourse.devontechnologies.com/t/dojavascript-on-a-markdown-preview/87443/6 "2026-08-10T15:49:24Z")

</div>

> [@chrillek](#):
>
> That’s why I was thinking of this slightly contrived approach…

I recognized right away what you’re planning 😉 Well, there will be some Markdown related improvements in the next release but one step after another…
