如何只允许更改行和链接,自动链接。使用showdown https://github.com/showdownjs/showdown禁用所有其他功能?
(如字体样式,标题,列表样式,图像......)
我看到有subParsers文件夹,有没有办法使用它,我可以选择解析我想要的东西,比如
var html = showdown.subParser('autoLink');
html = showdown.subParser('..')
...
JS
var showdown = require('showdown');
var converter = new showdown.Converter();
converter.setOption('noHeaderId', true);
converter.setOption('ghCodeBlocks', false);
converter.setOption('literalMidWordUnderscores', true);
var html = converter.makeHtml(d);
console.log(html)
https://jsfiddle.net/60bjuob8/4/
showdown.extension('myext', function() {
return [{ type: 'lang', regex: /^#/gm, replace: '\\#' }];
});
$('.convert').on('click', function() {
var cnv = new showdown.Converter({extensions: ['myext']});
var txt = $('#foo').val();
var html = cnv.makeHtml(txt);
$('#bar').val(html);
});