Lucius Digital: A rich text editor in a custom Drupal form, example code including data sanitization for security

A rich text editor in a custom Drupal form, example code including data sanitization for security
I needed to implement a rich text editor in a custom form (for the Drupal intranet distribution OpenLucius). I couldn’t find a complete working solution right away, but I figured it out. So, for anybody who needs rich text editing: here is some example code.