# How to run Javascript on Markdown "summarize highlights" output?

**URL:** <https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375>\
**Category:** Automation\
**Created:** [January 29, 2020, 2:54pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375 "2020-01-29T14:54:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![derekvan](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@derekvan](https://discourse.devontechnologies.com/u/derekvan)\
**Post date:** [January 29, 2020, 2:54pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/1 "2020-01-29T14:54:10Z")

</div>

I’m hoping for some help here with scripting the output of the “Summarize Highlights” feature with Markdown output. I would like to rearrange the text somewhat. I know a little javascript from working with Drafts and have put together the following script which achieves what I’m looking for in terms of text replacement:

```auto
let d = draft.content;
let regex = /(^## )(.*)\n(^\* )(.*)/gm;
let newDraft = d.replace(regex,'$4 ($2)');
draft.content = newDraft;
draft.update();

```

I’m wondering if anyone can help me port that over to DevonThink. I know that basically lines 2 & 3 are the key lines, but I don’t know several key things:

- how do I grab the text from the DevonThink markdown file?
- how do I then overwrite that text with this regex replacement and save?
- how do I make this run automatically when creating a markdown highlights file?

As you can tell, I’ve not ever created a javascript file for the Mac, only so far working with web stuff or Drafts. I’ve got some experience editing applescripts, but I really don’t know that system well–I’ve more knowledge of javascript in general, just not how to use it for Mac scripting. Any help here or pointers to the right resources would be much appreciated!

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [January 29, 2020, 3:04pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/2 "2020-01-29T15:04:05Z")

</div>

How about an example of what you have in the document and what you’re expecting to change it to?

And why would this need to be run automatically when making a Summary document?

---

<div class="post-metadata">

**Author:** ![derekvan](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@derekvan](https://discourse.devontechnologies.com/u/derekvan)\
**Post date:** [January 29, 2020, 3:12pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/3 "2020-01-29T15:12:43Z")

</div>

Same reason as expressed in [this thread](https://discourse.devontechnologies.com/t/customize-the-output-of-summarize-highlights/51341)–I want to change what the output of summarize highlights looks like.

initial output:

```auto
# [ahmed interviews butlet.pdf](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F)

## [Page 1](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F?page=0)
* SA: I have been asked to interview you about Gender Trouble and how this book has shaped the field of Queer Studies. In the preface to the second edition of Gender Trouble, you write that ‘the life of the text has exceeded my intentions, and this is surely in part because of the changing context of its reception’. I really like this description. I like the idea that texts have lives other than the ones we give them as writers, and that these lives are partly about how texts are ‘picked up’.

## [Page 2](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F?page=1)
* Could you reflect a little on this textual moment, and also about the extent to which you have drawn on your experience in generating critical insights and why you would or would not make that explicit in the text?

## [Page 4](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F?page=3)
* There is, of course, vulnerability in taking the risk, knowing one will be called a name, or worse, but there is also a vulnerability in the name of which one acts, and which informs one’s very acting. After all, responding with indignation to injury means that one has been affected by that injury, and that being affected is not a fully passive condition. Vulnerability can be the condition of responsiveness – something affects us, or we find ourselves affected; we are moved to speak, to accept the terms by which we are addressed, or to refuse them, or, indeed, to skew them or queer them in direc- tions that, yes, as you have shown, deviate from what seem to be their original aims. Indeed, I would suggest that there are two dimensions of gender performa- tivity from the start: one is the unchosen or unwilled situation of gender assign- ment, one that we can come to deliberate about and change in time; the other is performative action that takes up the terms by which we have been addressed (and so a retaking, a taking over, or a refusal), the categories through which we have been formed, in order to begin the process of self-formation within and against its terms.

```

desired output:

```auto
# [ahmed interviews butler.pdf](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F)

SA: I have been asked to interview you about Gender Trouble and how this book has shaped the field of Queer Studies. In the preface to the second edition of Gender Trouble, you write that ‘the life of the text has exceeded my intentions, and this is surely in part because of the changing context of its reception’. I really like this description. I like the idea that texts have lives other than the ones we give them as writers, and that these lives are partly about how texts are ‘picked up’. ([Page 1](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F?page=0))

Could you reflect a little on this textual moment, and also about the extent to which you have drawn on your experience in generating critical insights and why you would or would not make that explicit in the text? ([Page 2](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F?page=1))

There is, of course, vulnerability in taking the risk, knowing one will-be called a name, or worse, but there is also a vulnerability in the name of which one acts, and which informs one’s very acting. After all, responding with indignation to injury means that one has been affected by that injury, and that being affected is not a fully passive condition. Vulnerability can be the condition of responsiveness – something affects us, or we find ourselves affected; we are moved to speak, to accept the terms by which we are addressed, or to refuse them, or, indeed, to skew them or queer them in directions that, yes, as you have shown, deviate from what seem to be their original aims. Indeed, I would suggest that there are two dimensions of gender performativity from the start: one is the unchosen or unwilled situation of gender assignment, one that we can come to deliberate about and change in time; the other is performative action that takes up the terms by which we have been addressed (and so a retaking, a taking over, or a refusal), the categories through which we have been formed, in order to begin the process of self-formation within and against its terms. ([Page 4](x-devonthink-item://C102E4EF-878E-4CCB-A158-277C466EB18F?page=3))

```

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [January 29, 2020, 4:04pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/4 "2020-01-29T16:04:32Z")

</div>

Like this… ?

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/2X/8/85006c0a3eb1717e94ecec990c25f3fa6075175d.jpeg)

---

<div class="post-metadata">

**Author:** ![derekvan](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@derekvan](https://discourse.devontechnologies.com/u/derekvan)\
**Post date:** [January 29, 2020, 4:07pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/5 "2020-01-29T16:07:53Z")

</div>

exactly

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [January 29, 2020, 4:11pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/6 "2020-01-29T16:11:36Z")

</div>

Since the source is very well-formed, this is pretty trivial in pure AppleScript _(and @cgrunenberg likes pure AppleScript solutions for their ease of understanding 🙂 )_. Here is a _teaching edition_ script that makes those modifications to the output of our Summarize Highlights command…

```auto
tell application id "DNtp"
	repeat with thisRecord in (selection as list)
		-- Loop through selected documents
		
		if (type of thisRecord as string) = "markdown" then
			-- Only process Markdown docs
			
			set newText to {}
			-- Set up an empty list to push the paragraphs into)
			
			set currentText to (plain text of thisRecord)
			-- Get the current text of the document
			
			repeat with thisLine in (paragraphs of currentText)
				-- Loop through the document, paragraph by paragraph
				
				if thisLine begins with "##" then
					-- If this is an H2 page link
					set cachedText to (characters 4 thru -1 of thisLine as string) -- Cache all but the control characters in a variable
					
				else if thisLine begins with "* " then
					-- If it's just a bulleted paragraph 
					
					copy ((characters 3 thru -1 of thisLine as string) & " (" & (cachedText) & ") " & return) to end of newText
					-- Get all but the control characters and concatenate the cachedText.
					-- Then push it to the newText list
				else
					copy thisLine & return to end of newText
					-- Anything else, including the H1 line at the top, just push into the newText list
				end if
			end repeat
			
			set plain text of thisRecord to (newText as string)
			-- Set the text of the document to the new text
			
		end if
	end repeat
end tell

```

---

<div class="post-metadata">

**Author:** ![derekvan](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@derekvan](https://discourse.devontechnologies.com/u/derekvan)\
**Post date:** [January 29, 2020, 4:14pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/7 "2020-01-29T16:14:10Z")

</div>

Thanks so much, this is great.

Also: I picked up the idea somewhere that with the new rules in DT3, one could fire a script upon choosing “Summarize Highlights”, meaning that anytime I summarize highlights to markdown, the script you shared would run and replace the text in those ways. Is that correct? If so, how can I set this up?

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [January 29, 2020, 4:31pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/8 "2020-01-29T16:31:31Z")

</div>

No, there is no **On Summarize** event trigger in smart rules.

It is possible to target a location _(and I always suggest being more specific than general in smart rules)_ and use the **On Creation** trigger.

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/2X/6/6ac5e3dc4cbec2e3ebf5cac0f218f548cdccd30f.jpeg)

- Targeting a specific group here, though it could be a broader group, an Inbox, or a database. _(Again, I shoot for safety first.)_
- Looking **only** for Markdown docs ending with **Summary** _(again, **specific** )_.
- **On Creation** run the script.
- The sound is optional. I like it for debugging as I know it triggered.
- You may want to add another action to change the files so they’re not continuously matched by the smart rule. this can be a move out of the targeted group, a change of name, etc.

[Modify Markdown Summaries.dtSmartRule.zip](https://discourse.devontechnologies.com/uploads/short-url/seiSz2oNvOi7bvHaiPDvEqFFwbq.zip) (2.5 KB)

---

<div class="post-metadata">

**Author:** ![derekvan](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@derekvan](https://discourse.devontechnologies.com/u/derekvan)\
**Post date:** [January 29, 2020, 4:46pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/9 "2020-01-29T16:46:48Z")

</div>

Great. Thanks for this mini tutorial!

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [January 29, 2020, 5:05pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/10 "2020-01-29T17:05:14Z")

</div>

You’re welcome. I hope it _learns you something_ 😉 😛

---

<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:** [January 30, 2020, 7:51am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/11 "2020-01-30T07:51:29Z")

</div>

> [@BLUEFROG](#):
>
> @cgrunenberg likes pure AppleScript solutions for their ease of understanding 🙂

That’s true 🙂

---

<div class="post-metadata">

**Author:** ![houthakker](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/houthakker/32/9739_2.png) [@houthakker](https://discourse.devontechnologies.com/u/houthakker)\
**Post date:** [February 2, 2020, 11:03pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/12 "2020-02-02T23:03:43Z")

</div>

Very much agree on avoiding Regex where possible ( not quite _write-only_, but getting there, and they add a second layer of complexity ).

But the ‘_readability_’ of AppleScript is not a function of its inherent properties – it just expresses how much time we’ve personally spent with it. (I can remember finding it very opaque, and hard to write, for quite a while, despite a 20 year background at the time, in languages like C, Pascal, Prolog and Lisp).

We probably shouldn’t kid ourselves, or ask others to drink the ‘_English-like_’ Kool-Aid, on that one 🙂

Now that AppleScript’s development is sunsetted, and iOS is a bigger platform than macOS, perhaps it’s getting rather late in the day to push users back from JavaScript towards AppleScript ?

(I understand the impulse, we are all attached to the tools which happen to be familiar to us, but that doesn’t automatically make them the best choice – or the most responsible recommendation – for beginners).

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [February 2, 2020, 11:18pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/13 "2020-02-02T23:18:26Z")

</div>

> (I understand the impulse, we are all attached to the tools which happen to be familiar to us, but that doesn’t automatically make them the best choice – or the most responsible recommendation – for beginners).

JavaScript is familiar to you but terse and inexplicable to most laypeople.  
And I would **not** advocate people move into JXA as a beginner, especially since it’s very poorly documented and makes a ton of assumptions about a person’s prior knowledge.

There are quite a few people who have taken a shine to AppleScript, just from posts on these forums, our built-in **Help** , and the scripts we’ve included with DEVONthink. And the fact that Script Debugger continues to sell and flourish speaks to the general health and interest in AppleScript as a primary automation language for Macs.

Interestingly, you are another example of people coming from higher-level languages who said they struggled with AppleScript’s syntax.

I, having no CS degree, taught myself out of necessity in the graphic arts/printing field, then later professionally AppleScripting in the corporate world _(no, not a typo or exaggeration)_ and have always found AppleScript easy to grasp, easy to teach, and charming _(despite it’s occasional idiosyncracies)_.

---

<div class="post-metadata">

**Author:** ![houthakker](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/houthakker/32/9739_2.png) [@houthakker](https://discourse.devontechnologies.com/u/houthakker)\
**Post date:** [February 3, 2020, 12:07am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/14 "2020-02-03T00:07:33Z")

</div>

I disagree (and incidentally, neither of us has any formal training in CS), I was very familiar with AppleScript long before I knew any JS at all.

I now find it:

- Faster and easier to get things working in JS than in AppleScript,
- much easier than AppleScript to get help with.

> “very poorly documented”

Simply not true.

- JS is very much more fully documented and supported than AppleScript, and Apple now provide good parallel material in both languages. See for example: [MacAutomationScriptingGuide](https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ManipulateListsofItems.html)
- The first 10 chapters of [Eloquent JavaScript](https://eloquentjavascript.net)
- The online references at [Mozilla JavaScript Guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide)

> “it …makes a ton of assumptions about a person’s prior knowledge”

Not clear what the “it” refers to in that sentence … JS ? sorry – not clear what you have in mind …

> people coming from higher-level languages who said they struggled with AppleScript’s syntax

I came from both lower level languages and higher level languages, and still found AppleScript precious and opaque – in particular, **much** harder to write than to read.

> have “ **always found** ” AppleScript … _XYZ_ …

I think that’s the problem – long exposure to a language is very easily confused with the properties of the language itself. English speakers think English is easy and charming. Adult learners of it disagree.

I **now** find AppleScript perfectly legible and writable (I’ve contributed a fair amount of open source AppleScript in the past), but I don’t kid myself that it’s AppleScript _itself_ which “ **is** ” easy. Like anything, it can **become** easier. (If you invest a very significant amount of time).

Meanwhile, even on macOS:

- The Omni Applications have moved scripting development decisively away from AppleScript to JavaScript. See the discussion in their [2020 Road Map](https://www.omnigroup.com/blog/omni-roadmap-2020).

> … AppleScript had some big caveats: it was generally easy to read, but it was a fairly esoteric language that many developers found less easy to write. It was able to accomplish some amazing things, much faster and more accurately than working by hand—but it was generally slow enough that you could watch it work, and if it had a lot of work to do you could be watching and waiting for a while. And it was only available for the Mac platform—which was totally fine in the ’00s when that was the only place our apps ran, but was a lot less useful in the ’10s when our customers were increasingly spending their time on mobile devices.

- The excellent [TaskPaper](https://www.taskpaper.com) and [macOS Drafts](https://getdrafts.com) are both JavaScript-only.

Perhaps we need to think carefully before telling customers that AppleScript “ **is** ” easy, as if learning to use it confidently and productively (without wasting hours of frustration) doesn’t need to represent a **major investment of time**.

The reality is that all languages require time to learn, and we have no evidence **at all** to show that JavaScript would require a different amount of time from AppleScript.

What we **do** have evidence of, however, is that JS is bound to be a **better investment** of that time.

- AppleScript has a small and shrinking pool of applications, and no prospect of further development.
- iOS is JavaScript-only (there can and will never be any AppleScript on it)
- macOS has no AppleScript-only applications, but it **does** have JavaScript-only applications.
- OmniGroup is moving away from AppleScript development to JS scripting development.
- Web pages run on JavaScript – if you’re only going to learn one language, JS is the language to learn, and it’s the one with the richest range of learning materials.

I do understand the reflex of defending a technology that one has personally invested time in, and the vertiginous avoidance of stepping into a new one – I felt it myself at the transition from familiar use of AppleScript to first steps in JavaScript (which I originally made simply in order to be able to write scripts for TaskPaper).

But I think it’s only responsible to allow oneself to pause and reflect that the picture is now **very** different for beginners.

---

<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:** [February 3, 2020, 9:17am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/15 "2020-02-03T09:17:34Z")

</div>

> [@houthakker](#):
>
> English speakers think English is easy and charming. Adult learners of it disagree.

Compared to other languages it definitely is - just try to learn Czech 😃

---

<div class="post-metadata">

**Author:** ![houthakker](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/houthakker/32/9739_2.png) [@houthakker](https://discourse.devontechnologies.com/u/houthakker)\
**Post date:** [February 3, 2020, 11:24am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/16 "2020-02-03T11:24:20Z")

</div>

( Tho I understand CZ was a bit divided on that one … )

---

<div class="post-metadata">

**Author:** ![mbbntu](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mbbntu](https://discourse.devontechnologies.com/u/mbbntu)\
**Post date:** [February 4, 2020, 7:45am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/17 "2020-02-04T07:45:41Z")

</div>

Having spent the best part of ten years teaching English to adult learners in another country, I have my doubts about that proposition (though I concede that Czech is not easy – I have friends who live there). The fact that huge numbers of native English speakers appear to be incapable of speaking or writing the language correctly only adds weight to the idea that it is not an easy language. But I have taken us off topic …

---

<div class="post-metadata">

**Author:** ![perryfr](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/p/b5ac83/32.png) [@perryfr](https://discourse.devontechnologies.com/u/perryfr)\
**Post date:** [February 18, 2020, 12:09am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/18 "2020-02-18T00:09:04Z")

</div>

**I’m tempted to dig into the 800+ pages of Sal Soghoian’s book on Apple Script, but I’m guessing someone in this thread could tweak BLUEFROG’s script for me so that I do something very similar with my Kindle highlights. I’d like to turn this…**

Yellow highlight | Location: 1,121  
For a time, we had come to believe that civilization moved in the other direction—making the impossible first possible and then stable and routine. With climate change, we are moving instead toward nature, and chaos, into a new realm unbounded by the analogy of any human experience.

Yellow highlight | Location: 1,131  
On local golf courses, the West Coast’s wealthy still showed up for their tee times, swinging their clubs just yards from blazing fires in photographs that could not have been more perfectly staged to skewer the country’s indifferent plutocracy. The following year, Americans watched the Kardashians evacuate via Instagram stories, then read about the private firefighting forces they employed, the rest of the state reliant on conscripted convicts earning as little as a dollar a day.

**…into this…**

For a time, we had come to believe that civilization moved in the other direction—making the impossible first possible and then stable and routine. With climate change, we are moving instead toward nature, and chaos, into a new realm unbounded by the analogy of any human experience. (Location: 1,121)

On local golf courses, the West Coast’s wealthy still showed up for their tee times, swinging their clubs just yards from blazing fires in photographs that could not have been more perfectly staged to skewer the country’s indifferent plutocracy. The following year, Americans watched the Kardashians evacuate via Instagram stories, then read about the private firefighting forces they employed, the rest of the state reliant on conscripted convicts earning as little as a dollar a day. (Location: 1,131)

**In other words, I’d like to**  
**1. get rid of “Yellow highlight |” at the top of each passage,**  
**2. create parentheses at the end of each passage,**  
**3. relocate “Location: xxxx” from the top of each passage into the parentheses at the end of the passage.**

**I don’t need this to happen within DEVONthink, though no problem if that’s what you think is easiest. I was thinking I could copy and paste my highlights into a regular text file and then run the script on each file individually. Oh, and I have Keyboard Maestro, so if you think that’d be even better to use, please oh please send some instructions my way.**

**Thank you in advance for whatever help you can provide!**

---

<div class="post-metadata">

**Author:** ![jasondm007](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/jasondm007/32/9334_2.png) [@jasondm007](https://discourse.devontechnologies.com/u/jasondm007)\
**Post date:** [February 27, 2020, 9:13pm UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/19 "2020-02-27T21:13:43Z")

</div>

@BLUEFROG By chance, do you have a nice learning example for formatting RTF files?

I’m looking for an easy way to **remove the indents from the Summarize Highlights RTF** output (i.e., so that all the text is left-aligned and indent free). When compared to your markdown examples above, it would look more like the version on the right-hand side. However, I don’t really care if the links are moved to parentheses after the quote; they can stay above the text, like the default output, or move - either is fine. I just don’t like the indents because they’re more difficult to fix manually afterward.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![OAL](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/o/e95f7d/32.png) [@OAL](https://discourse.devontechnologies.com/u/OAL)\
**Post date:** [February 8, 2021, 1:41am UTC](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375/20 "2021-02-08T01:41:07Z")

</div>

> [@BLUEFROG](#):
>
> [Modify Markdown Summaries.dtSmartRule.zip](https://discourse.devontechnologies.com/uploads/short-url/seiSz2oNvOi7bvHaiPDvEqFFwbq.zip) (2.5 KB)

Hey Jim, @BLUEFROG, Could you be so kind as to modify this code so that:

Instead of Page, it writes the name of the file in the paranthesis in the following format(semicolon)?

Right Now:

 ![Screenshot 2021-02-08 at 02.34.06 copy](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/6/2/6285a663befa3ee73f4abf5bbfc3887a9da00ce8.png)

How I would love it to be:

 ![Screenshot 2021-02-08 at 02.34.06](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/3/b/3bcfe6f5b69422f4884d49445f48407c89b0faac.png)

[Next page](https://discourse.devontechnologies.com/t/how-to-run-javascript-on-markdown-summarize-highlights-output/53375.md?page=2)
