mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Make markdown wikitext links readable (#8402)
This commit is contained in:
parent
b48be91ec5
commit
bfb9c38c42
@ -13,15 +13,15 @@ Text editor operation to make a markdown link
|
||||
"use strict";
|
||||
|
||||
exports["make-markdown-link"] = function(event,operation) {
|
||||
var rx = /[()\\]/g, rs = '\\$&';
|
||||
var rx = /[()<>\\]/g, rs = '\\$&';
|
||||
|
||||
if(operation.selection) {
|
||||
var desc = operation.selection.replace(/[\[\]\\]/g, rs);
|
||||
|
||||
if(event.paramObject.text.indexOf("://") !== -1) {
|
||||
operation.replacement = "[" + desc + "](" + event.paramObject.text.replace(rx, rs) + ")";
|
||||
operation.replacement = "[" + desc + "](" + event.paramObject.text.replace(/[()\\]/g, rs) + ")";
|
||||
} else {
|
||||
operation.replacement = "[" + desc + "](#" + encodeURIComponent(event.paramObject.text).replace(rx, rs) + ")";
|
||||
operation.replacement = "[" + desc + "](<#" + event.paramObject.text.replace(rx, rs) + ">)";
|
||||
}
|
||||
operation.cutStart = operation.selStart;
|
||||
operation.cutEnd = operation.selEnd;
|
||||
@ -31,7 +31,7 @@ exports["make-markdown-link"] = function(event,operation) {
|
||||
return encodeURI(m);
|
||||
}) + ">";
|
||||
} else {
|
||||
operation.replacement = "[](#" + encodeURIComponent(event.paramObject.text).replace(rx, rs) + ")";
|
||||
operation.replacement = "[](<#" + event.paramObject.text.replace(rx, rs) + ">)";
|
||||
}
|
||||
operation.cutStart = operation.selStart;
|
||||
operation.cutEnd = operation.selEnd;
|
||||
|
Loading…
Reference in New Issue
Block a user