Add new span class for some custom marker

For example, the bold content is in two star markers **, the text has a special class for it in the editor mode. I want this support other custom markers, like the text in has a class .cm-underline so I can add a underline style in .css file, but not only in the preview mode. I assume I can do this by writing a plugin, but I have no idea how to write the typescript.