Jump to content

Support HTML format for snippets and copy to clipboard action


Recommended Posts

Currently for snippets and for the "Copy to Clipboard" output in workflows we can choose between "Plain Text" and "Richt Text". I would like to see a third option "Paste HTML".

 

Typinator allows exactly this and the good thing is, that it allows me to easily write text including links with titles to Microsoft Teams. For example if the following text is pasted to teams as HTML, the text will use Team's default text format and will include a titled link:

Try out <a href="https://www.alfredapp.com">Alfred</a> – a super cool productivity solution for macOS.

The only workaround at the moment is to write the required text in Teams with the link, copy and paste it into the snippet and paste it as "Richt Text". Unfortunately this does not support generating dynamic links and further it produces links in Microsoft Teams which do have the standard text color instead of the expected link color.

Link to comment
Share on other sites

Welcome @eiselch,

 

HTML is just plain text, so “paste HTML” wasn’t making sense to me. I checked the Typinator page, and what they say is the feature is an expansion format described in HTML. It still outputs rich text, it’s just the input that is HTML. This could be faked with a Workflow by using textutil to convert from HTML to RTF, though I agree this would be best supported natively in the snippets feature.

4snRD9x.png

Link to comment
Share on other sites

Thanks @vitor for the info. I really thought it would paste with a specific MIME type which would then be interpreted by MS Teams and other web based apps.

 

Thanks for the tip for textutil. Wasn't aware of this tiny command line tool. Nevertheless as it expects input files it is quite unhandy for simple text expansion.

Link to comment
Share on other sites

1 hour ago, vitor said:

HTML is just plain text, so “paste HTML” wasn’t making sense to me

 

So is rich text, tbf. As far as the pasteboard is concerned, what matters is which UTI you assign to the data (public.rtf, public.html or public.utf-8-plain-text).

 

1 hour ago, vitor said:

This could be faked with a Workflow by using textutil to convert from HTML to RTF

 

That tends to suck, unfortunately, because textutil always adds styling to snippets, so if you just feed in <a href="...">Some Link</a>, it will come out in Times Roman.

 

I had to build a custom HTML -> RTF converter for ZotHero (though I'm not using it any more, IIRC: the Python version of citeproc was terrible.)

Edited by deanishe
Link to comment
Share on other sites

1 hour ago, eiselch said:

Nevertheless as it expects input files it is quite unhandy for simple text expansion.

 

Not if you give it the -stdin flag. It’s not on the page I linked, but you’ll find it in man textutil.

 

33 minutes ago, deanishe said:

So is rich text, tbf. As far as the pasteboard is concerned, what matters is which UTI you assign to the data (public.rtf, public.html or public.utf-8-plain-text).

 

Fair enough. I was making the distinction at what people write by hand. We don’t expect to (and mostly can’t) tinker with RTF code directly after it has been pasted, though we do with HTML.

 

39 minutes ago, deanishe said:

That tends to suck, unfortunately, because textutil always adds styling to snippets, so if you just feed in <a href="...">Some Link</a>, it will come out in Times Roman.

 

I had to build a custom HTML -> RTF converter for ZotHero (though I'm not using it any more, IIRC: the Python version of citeproc was terrible.)

 

True. I also did something like that in MarkdownTransform. Since I’m already getting the HTML code from the Markdown anyway, I’ve just added a few styles and told textutil to convert from HTML to RTF.

 

I also have note that I fake ⌘V to paste the RTF text, because passing it through Alfred, even if saying to paste as Rich Text, gets us plain text with the RTF syntax showing.

Link to comment
Share on other sites

21 minutes ago, vitor said:

because passing it through Alfred, even if saying to paste as Rich Text, gets us plain text with the RTF syntax showing.

 

Yeah. I think the Rich Text only applies to what you've pasted in the box in the Copy to Clipboard element.

 

As best as I can tell, you can’t even use a JSON Config to get Alfred to treat your own input as RTF: it ignores the clipboardtextrtf setting and uses clipboardtext converted to RTF instead.

 

Is this the case, @Andrew, and shouldn't Alfred use the RTF passed to it via JSON Config? It would be handy to be able to put "pretty" links on the clipboard alongside plaintext URLs, without having to faff about doing all the clipboard manipulation yourself.

Edited by deanishe
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...