-- All logic is within the WYSIWYG editor, and therefore you won't get the same functionality via the API or other editors.
-- The syntax & code used likely won't be cross-compatible with the markdown editor.
-- This has been tested to some degree but there's a reasonable chance of bugs or side affects, since there's quite a lot going on here.
-- There's a lot of custom code here. You could instead put this code (without the HTML `<script>` tags) in an external JavaScript file and then just use a single `<script src="/path/to/file.js"></script>` within the custom head setting.