How can I render plain text as HTML in a template?
A solution by iworkyon from the Drupal community:
field--node--[field name].html.twig:
{% if svg %}
  &lt;div class=&quot;my-svg&quot;&gt;
    {{ svg|raw }}
  &lt;/div&gt;
{% endif %}

MYTHEME.theme:
/**
* Implements hook_preprocess_field().
*/
function MYTHEME_preprocess_field(&amp;$variables, $hook) {
    switch ($variables['element']['#field_name']) {
      case 'field_svg_test':
        $variables['svg'] = $variables['items'][0]['content']['#context']['value'];
        break;
    }
}