JS style commenting in markdown mode

Hello all! I’d like to add JS style commenting capabilities (// and /* */) to the markdown mode (markdown.js). Is there an easy way to do that? The code in mode files seems quite complex. Thanks.
iztok

Markdown does not by default support such comments, so you’d probably best implement it outside of the Markdown mode. A mode overlay seems like a good option.

I looked into it and this indeed is not hard. One more question, please: is it possible to serialize (json) the CodeMirror.Doc object? I get an error - circular json operation or smth like this. To put it another way - which parts are serializable? What I want is to save codemirror documents with as many data as possible.

Thanks in advance for your time and wonderful(!!) component.

Iztok

What do you want to serialize? The main thing that a document holds is its content, which you get as a string from getValue. You could also store the modeOption property to restore the mode, and the cursor positions, and even the undo history (see the getHistory method).

I just thought doc object also holds info about which parts are folded so I could restore exact state of the view out of the box. Thanks for your answer!
iztok

It does, but there’s currently no convenient way to serialize those. You can call getAllMarks and do your own serialization, but that requires some glue code.