I am writing blog posts in Mark Text using Markdown.
When a post is completed I have Mark Text export the post as HTML to the clipboard.
I use the following AppleScript on my Desktop to inject spans into HTML listitems within some of the posts.
set C to the clipboard
set the C to replaceText("<li>", "<li><span class=\"b\">β </span>", C)
set the C to replaceText("</p>", "<span class=\"r\"><br></span></p>", C)
on replaceText(find, replace, textString)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to find
set textString to text items of textString
set AppleScript's text item delimiters to replace
set textString to "" & textString
set AppleScript's text item delimiters to prevTIDs
return textString
end replaceText
set the clipboard to C
Presently each document in Mark Text has a YAML section at the top that I use for each blog title. I donβt want this in the actual post so I must presently manually scroll just below the YAML and press Command + Shift + Down Arrow.
It would be much faster to be able to press Command + A anywhere in the document and then export the post as HTML to the clipboard. This however, leaves the unwanted YAML matter in the HTML.
I need to add code to the above script to remove the YAML matter. Each YAML has the following structure, with the text between the code tags always being different. This YAML matter is always found at the top of the document.
Can regex be used with Applescript to remove this OR is there another method which will remove this pattern consisting of random text between the always present pre and code tags?
<pre><code class="fenced-code-block language-yaml">Title Will Be Different for Each YAML
</code></pre>