Search code examples
markdowncodemirror

Codemirror Markdown level classes for headers


using codemirror with markdown mode, how can I have individual classes for all headline levels.

e.g.

# headline <- class cm-header and cm-header-1
## headline level 2 <- class cm-header and cm-header-2

Thanks.


Solution

  • I had exactly the same issue, so changed my markdown.js file to look like this Gist. Once you change your mode for this it will append one of 3 different CSS styles as follows:

    #Header 1 = .cm-header1
    ##Header 2 = .cm-header2
    ###Header 3 = .cm-header3
    

    Hope that helps!