有没有人知道如何使用挂钩或编辑来自Pagedown的Markdown.Editor.js
来创建内联链接而不是引用链接?
同样,我想在单击链接按钮时发生这种情况:
[inline link](http://www.google.com)

而不是:
[referenced link][1]
![referenced image][2]
[1]: http://google.com/
[2]: http://website.com/bear.jpg "title text"
谢谢!
答案 0 :(得分:2)
不幸的是,Markdown.Editor.js
中似乎没有任何关于此功能的钩子。然而,我能够找到负责此的代码部分,并为您所需的功能创建一个补丁。
Markdown.Editor.js
。找到这段代码:
var linkDef = " [999]: " + properlyEncoded(link);
var num = that.addLinkDef(chunk, linkDef);
chunk.startTag = isImage ? "![" : "[";
chunk.endTag = "][" + num + "]";
替换为此代码:
chunk.startTag = isImage ? " + ")";
利润!
答案 1 :(得分:0)
Markdown.Converter.js
function _DoImages(text) {}
function _DoAnchors(text) {}
最后,通过编辑源代码,您可以获得绝对任何可想象的结果。
UPD:
只是为了好玩补丁(如果您更喜欢补丁):
converter.hooks.chain("postConversion", function (text) {
var anchors = [];
// definitions
text = text.replace(/\[(\d+)\]\: (htt.+)\n/gi, function(anchor_definition){
anchors.push(anchor_definition.match(/(htt.+)\n/i)[1]);
return("");
});
// anchors in the text
text = text.replace(/\]\[\d+\]/gi, function(anchor){
var id = parseInt(anchor.match(/\d+/)[0]);
var code = "][" + (anchors[id - 1]) + "]";
return(code);
});
return(text);
});