hackmdio/codimd

CodiMD Document Extensions - request for comments

Open

#1,023 opened on 2018年10月22日

GitHub で見る
 (5 comments) (3 reactions) (0 assignees)JavaScript (8,949 stars) (1,038 forks)batch import
discussionhelp wanted

説明

(very loosely related to #787, as this is very very focused on how document rendering itself can be extended)

Right now, a lot of rendering is extended in public/js/extra.js. Among other things, it handles highlighters, mermaid, video plugins and so on. For the following, I'll use mermaid as an example, because I'm familar with how it works.

I would love if we came up with a common interface for things like that. This way we could get much of the code out of extra.js, and we might end up with more extensions along the way!

Basically, Mermaid is applied in three steps.

So basically, I propose a plugin or extension system that would take those commonalities so we could easily write more such additions, and also that could perhaps be lazy-loaded. Or they could even be distributed in a different way (think: their own NPM modules)

// example Document Extension
{
  keyword: 'mermaid',
  highlightRender: (code) => {
    // returns a html element for later processing
    return htmlElement;
  },
  finishView: (view) => {
    // modifies element in place
  }
}

perhaps we could even get away from that extra step and just pass an object reference right into finishView or something.

  • Name: Is "Document Extensions" the right name?
  • User expectation: how do we deal with different CodiMD instances offering different functionalities?
  • Do we need anything more than what's proposed? Does ony one of you know other extensions that would need different things?

コントリビューターガイド