What you need for the above:
How to host text files on Github
How to embed files hosted on Github (see 2b)
If you still need to do this within rich-text, it’s possible with even more custom code - all you need is to detect a “placeholder” and replace it with the external content.