How can I programmatically apply text formats? I've created a custom text format I'm trying to apply to a field programmatically. As best I can tell, the format IS getting applied, but it is not stripping HTML tags like it is supposed to. The below screenshot shows how my text formatter is configured:



As you can see, its supposed to filter &lt;span&gt; tags. The Nodes where this will be used get created programmatically, and I apply the text formatter as follows:

'field_career_job_description1' =&gt; ['value' =&gt; $job['jobdesc'],'format' =&gt; 'careers_html_formatter']


This appears to be working correctly, if I print the variables passed to twig, I see that the formatter is, indeed, my custom format:



However, as you can see in the sshot, &lt;span&gt; tags are still in the text. 

Note that I am displaying the field in question in Twig as follows:

{{ content.field_career_job_description1[0]['#text'] | raw }}
As I was pressing post on this question, I realized the problem. It's the twig code. In order to get the text formatter properly applied, I had to call my field as follows:

{{ content.field_career_job_description1 }}

Leaving this question up because I couldn't find anything like it on google