I use when pressing hotkeys to change the selected text in CodeMirror using the doc.markText method. By default, it wraps in a span.
doc.markText(from: {line, ch}, to: {line, ch}, ?options: object) → TextMarker options:
className: string Assigns a CSS class to the marked stretch of text. css: string A string of CSS to be applied to the covered text. For example "color: #fe3". Through options, I can apply a class or linear style. And what needs to be done to apply another tag not a span such as code or q?