Can a replacing decoration generate a string instead of an HTMLElement

Let me give a bit more background info:
I’m extending CodeMirror that is being used by the Obsidian markdown app so it makes things a bit more complex. Obsidian has a feature called LivePreview where in a single CodeMirror editor, it will show the source markdown on the lines where something is selected and everywhere else, it will actually generate the HTML corresponding to the source markdown. So basically, as you type, you modify the source markdown but everything around it is the generated HTML preview of the markdown.

My Obsidian plugin detects which lines are in LivePreview mode and then I find matches for the user’s configured variables and swap the variable name with the variable value via a Decoration.replace and a custom WidgetType. Now, that is working except that a WidgetType's toDOM() method has to return an HTMLElement so I’m generating the most non-intrusive element that I know of: HTMLSpanElement. The problem is that it messes up the formatting.

For example, it “breaks” the style of the header for the replaced content:
Peek 2022-03-19 15-24

So maybe there is another way to achieve what I want or maybe this is more of a feature request for toDOM() to return HTMLElement | string or something like that.