Omit <!––– comments ––> when sharing

Anyone know a way or aware of an action that will share or copy plain text (ex: to Messages or other apps that don’t support formatting) and omit MD comments formatted as <!--- this -->?

Comments get stripped out in (for example) the Markdown Mail action.

But I can’t find an elegant way to exclude them from sharing as a Message.

Firstly, I would note that those comments do not get stripped out when using Markdown Mail, or other methods that output to HTML from Markdown. They are HTML comments, and are not displayed when HTML is rendered, but if you were to view source of the HTML (or email message, etc.) those comments would still be there. This may or may not be important to you, but it’s worth noting, in case you are writing comments like <!-- what a moron -->. :grin:

It would be pretty easy to pre-process and remove HTML comments via script. Something like:

// remove comments
let s = draft.content.replace(/<!--[\s\S]*?-->/g, "");
// setup template tag
draft.setTemplateTag("cleaned", s);
// Now use [[cleaned]] in your subsequent message step template
// instead of [[draft]]
1 Like

LOL. That’s a great point. Fortunately, it’s just prompt lists for a daily report template. No harm, no foul. :slight_smile:

Thank you so much for this. I’ll give it a shot!

I’ll note that looks like single-line comments that get parsed by the RegEx. (If not I need to learn something more about RegExes, which is generally a true statement.) :slight_smile:

(In md2pptx I strip out comments - whether single- or multi-line. Programming for that was a bit of a pain, but not too bad. That code is Python so not useful to share it. I also embed some metadata parsing to fine-tune individual slides.)