mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-06-06 08:34:08 +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";
|
"use strict";
|
||||||
|
|
||||||
exports["make-markdown-link"] = function(event,operation) {
|
exports["make-markdown-link"] = function(event,operation) {
|
||||||
var rx = /[()\\]/g, rs = '\\$&';
|
var rx = /[()<>\\]/g, rs = '\\$&';
|
||||||
|
|
||||||
if(operation.selection) {
|
if(operation.selection) {
|
||||||
var desc = operation.selection.replace(/[\[\]\\]/g, rs);
|
var desc = operation.selection.replace(/[\[\]\\]/g, rs);
|
||||||
|
|
||||||
if(event.paramObject.text.indexOf("://") !== -1) {
|
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 {
|
} 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.cutStart = operation.selStart;
|
||||||
operation.cutEnd = operation.selEnd;
|
operation.cutEnd = operation.selEnd;
|
||||||
@ -31,7 +31,7 @@ exports["make-markdown-link"] = function(event,operation) {
|
|||||||
return encodeURI(m);
|
return encodeURI(m);
|
||||||
}) + ">";
|
}) + ">";
|
||||||
} else {
|
} else {
|
||||||
operation.replacement = "[](#" + encodeURIComponent(event.paramObject.text).replace(rx, rs) + ")";
|
operation.replacement = "[](<#" + event.paramObject.text.replace(rx, rs) + ">)";
|
||||||
}
|
}
|
||||||
operation.cutStart = operation.selStart;
|
operation.cutStart = operation.selStart;
|
||||||
operation.cutEnd = operation.selEnd;
|
operation.cutEnd = operation.selEnd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user