update: link markdown parser
This commit is contained in:
parent
66065ce7c2
commit
c587b0997e
|
@ -41,7 +41,7 @@ export default class<
|
|||
|
||||
markdown =
|
||||
this.options.markdown === undefined
|
||||
? '\\[(.+?)\\]\\(([\\S]+?)\\)$'
|
||||
? '\\[(.+?)\\]\\(s*([\\S]+?)\\s*\\)$'
|
||||
: this.options.markdown;
|
||||
|
||||
init() {
|
||||
|
@ -149,7 +149,7 @@ export default class<
|
|||
const text = node.text();
|
||||
if (!text) return;
|
||||
|
||||
const reg = /(\[(.+?)\]\(([\S]+?)\))/;
|
||||
const reg = /(\[(.+?)\]\(\s*([\S]+?)\s*\))/;
|
||||
const match = reg.exec(text);
|
||||
return {
|
||||
reg,
|
||||
|
@ -188,7 +188,7 @@ export default class<
|
|||
const url = match[3];
|
||||
|
||||
const inlineNode = $(`<${this.tagName} />`);
|
||||
this.setAttributes(inlineNode, '_blank', url);
|
||||
this.setAttributes(inlineNode, '_blank', (url || '').trim());
|
||||
inlineNode.html(!!text ? text : url);
|
||||
|
||||
newText += inlineNode.get<Element>()?.outerHTML;
|
||||
|
|
|
@ -43,7 +43,7 @@ export default class<T extends LinkOptions> extends InlinePlugin<T> {
|
|||
|
||||
markdown =
|
||||
this.options.markdown === undefined
|
||||
? '\\[(.+?)\\]\\(([\\S]+?)\\)$'
|
||||
? '\\[(.+?)\\]\\(\\s*([\\S]+?)\\s*\\)$'
|
||||
: this.options.markdown;
|
||||
|
||||
init() {
|
||||
|
@ -151,7 +151,7 @@ export default class<T extends LinkOptions> extends InlinePlugin<T> {
|
|||
const text = node.text();
|
||||
if (!text) return;
|
||||
|
||||
const reg = /(\[(.+?)\]\(([\S]+?)\))/;
|
||||
const reg = /(\[(.+?)\]\(\s*([\S]+?)\s*\))/;
|
||||
const match = reg.exec(text);
|
||||
return {
|
||||
reg,
|
||||
|
@ -190,7 +190,7 @@ export default class<T extends LinkOptions> extends InlinePlugin<T> {
|
|||
const url = match[3];
|
||||
|
||||
const inlineNode = $(`<${this.tagName} />`);
|
||||
this.setAttributes(inlineNode, '_blank', url);
|
||||
this.setAttributes(inlineNode, '_blank', (url || '').trim());
|
||||
inlineNode.html(!!text ? text : url);
|
||||
|
||||
newText += inlineNode.get<Element>()?.outerHTML;
|
||||
|
|
Loading…
Reference in New Issue