Remove CriticMarkup syntax from Summarize Highlights>Markdown?

Here is a script with a handler that scrapes CriticMarkup syntax from a Markdown file.
The handler can be called as a post-process step, if needed.
Note you must pass the plain text and the cached text item delimiter.

(* Uncomment for testing
tell application id "DNtp"
	my performSmartRule(selected records)
end tell *)

on performSmartRule(theFiles)
	tell application id "DNtp"
		set od to AppleScript's text item delimiters
		repeat with thisRecord in theFiles
			if (type of thisRecord as string) = "markdown" then
				set scrapedText to my scrapeCriticMarkup(plain text of thisRecord, od)
				set plain text of thisRecord to scrapedText
			end if
		end repeat
	end tell
end performSmartRule

on scrapeCriticMarkup(recText, od)
	set AppleScript's text item delimiters to {"{==", "==}", "{--", "--}", "{++", "++}", "{==", "==}", "{~~", "~>", "~~}", "\\"}
	set scrapedText to text items of recText
	set AppleScript's text item delimiters to od
	
	return (scrapedText as string)
end scrapeCriticMarkup

And here’s a sample smart rule that would strip the CriticMarkup once a Summary Markdown file is created…
Scrape CriticMarkup.dtSmartRule.zip (1.4 KB)

3 Likes