Apply text filter (not text format) in Twig Is it possible to apply a specific text filter (not a whole text format) to a string in Twig?
(Or at least in template preprocess, if not possible in Twig)

Use case:

I've a special block for hand-picked, trusted editors that allows them to inject unfiltered HTML (for social widgets like Facebook posts, TripAdvisor reviews, etc) into the homepage. Basically it is just a custom content block with a text field, and printed using |raw to avoid style and script tags being from filtered:

{{ content.body.0['#text']|raw }}

This does already work as expected.

Now I've got the additional requirement to apply the text filter from the LinkIt module on this field. The editors want to provide a link to a node, and the link to the node should be printed using the correct language prefix and the SEO-friendly URL alias. E.g. I've got a text field containing something like

&lt;script src="https://external.com/social_widget.js" async defer&gt;
&lt;div id="#placeholder_social_widget"&gt;&lt;!-- External widget does it's magic in here&lt;/div&gt;
&lt;script&gt;/* some scripts from us */&lt;/script&gt;
&lt;a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="whatever-123-abc-def"&gt;Link with correct language prefix and SEO-friendly URL-alias&lt;/a&gt;


and I want to run the LinkIt replacement on that field and then output it, but without filtering or escaping any of the JS or CSS.
If those HTML are mostly or all static, you could consider implementing your own tokens via hook_token_info() and hook_tokens() in your custom module. 

This way, you would avoid any potential risks, and accidentally malformed markup... and would have to full control on the replaced and returned markup.

Your authors would add a token like this in the content: [custom:facebookpost:12345]

... and your token could return an embedded Facebook post markup in return.

In my experience this method works much better than any other alternatives, mostly because: 


those embed widgets usually have custom tags and/or tag attributes which may not be compatible with CKEditor settings, text formats, etc.
embedding those widgets directly, would make maintaining content much harder on the long run. 
provider(s) may change the embed markup. (Consider updating 100s or thousands of content entries via find &amp; replace vs. updating the embed markup in token definition only)
and it's not a hack.