How does one integrate commonmark into a website?

Hi y’all. I recently discovered the commonmark project and I’m very excited about using it. However, I’ve been unable to find any explanation on how to actually integrate it into a website.

My understanding is that commonmark.js is supposed to parse markdown on the fly. Is that accurate?

If so, what do I do? I’ve got a copy of commonmark.js saved into one of my local web projects. But then what? I know it’s not as simple as plopping some .md files in there with the commonmark library, though I haven’t the foggiest on how to use it.

Any help would be much appreciated.


I’m not sure I feel that this is a relevant question on the discussion forum. Basically you’re asking not only how do I learn to use a particular implementation of a particular commonmark parser, but also how do I read the API and learn how to code.

I know this isn’t stackoverflow, and can be much more liberal in what we choose to allow as on- or off-topic, but this seems to be far too broad to me.

Why is it irrelevant to ask how one uses commonmark on the commonmark forums? How in the world is that “off-topic”?

As for my question being too broad, I just want to know how to use commonmark.js. I’m not asking about syntax or anything like that; I want to learn how to integrate into a website. Is that non-trivial? I had assumed it was as simple as sourcing the javascript library and then surrounding your markup with a particular block class. Is that not accurate?

Calm down! @zzzzBov shouldn’t have used that many words to say RTFM! and @paxperscientiam should have shown that they RTFM prior to asking.

@paxperscientiam, you could have a look at the source code for

1 Like

I think this is an OK question to have as a general “getting started”. We can do it at least once and then refer anyone else to this topic.

No need for anyone to be rude about it, I apologize @paxperscientiam – and we certainly don’t get dozens of topics like this per day or anything.

CommonMark is a language standard, not an implementation. You could use any one of the implementations in this list to integrate commonmark into your site:

Depending on which one you choose, the steps required to integrate it into your site will vary extremely widely. That’s why @zzzzBov was saying your question is too broad to answer.

It seems you’ve already decided to use commonmark.js though, so that definitely narrows things down. The steps neccessary to integrate that library into your site are covered in that project’s REAME.

Your idea of “sourcing the javascript library and then surrounding your markup with a particular block class” seems like it would be a reasonable API for a higher level library built on top of commonmark.js. I don’t know of one that does anything like that off the top of my head.

For future reference:

Commonmark is the standardization of Markdown. Markdown is, in the context of web publishing, typically a part of static website generators. For an overview of such generators see here and here.


1 Like