How to create a showdown.js markdown extension

后端 未结 2 1952
孤城傲影
孤城傲影 2021-01-14 17:35

Using the following code, I get working output:


  
    

        
2条回答
  •  梦谈多话
    2021-01-14 18:11

    The way we write extensions has changed, I found some help with the following filter example : http://codepen.io/tivie/pen/eNqOzP

    showdown.extension("example", function() {
      'use strict';
      return [
        {
          type: 'lang',
          filter: function(text, converter, options) {
            var mainRegex = new RegExp("(^[ \t]*:>[ \t]?.+\n(.+\n)*\n*)+", "gm");
            text = text.replace(mainRegex, function(match, content) {
              content = content.replace(/^([ \t]*):>([ \t])?/gm, "");
              var foo = converter.makeHtml(content);
              return '\n
    ' + foo + '
    \n'; }); return text; } } ] });

提交回复
热议问题