Space Script: Modifying rendering?

I want to try and implement a shortlink system, but I’m not sure where to start. I’m fairly sure I can do it with Space Script, but I’d like a pointer.

For a simpler starting point, in the spirit of the wonderful https://www.sansbullshitsans.com/, how would I go about implementing the following:

  1. Each time the word unicorn appears in markdown, instead render it as horse.
  2. Same, but render it as [horse](http://example.com) (ideally I’d like to specify markdown and have it be rendered, which would make it easier for this to be extensible).
  3. Same, but not if it’s inside a code block

These should be done without modifying the underlying markdown file.

Any ideas? Just messing around with the Javascript console I ran this:

document.body.innerHTML = document.body.innerHTML.replace(/unicorn/g, "horse");

…silverbullet did not like that, the document became uneditable.

You can’t realistically do this. To change the rendering inside CodeMirror you either have to build a CM plugin as part of the SilverBullet core, or you have to leverage some of the infrastructure that exist for creating custom renderers you can build for custom fenced code blocks, like the GitHub - silverbulletmd/silverbullet-mermaid: Mermaid support for Silver Bullet plug does (as a plug, but you could achieve something like this in space script if you really put your mind to it).