Support short-form markdown links [#54]

This commit is contained in:
David Evans 2018-05-07 01:12:27 +01:00
parent 4d4b22aa91
commit b74c806f24
5 changed files with 35 additions and 1 deletions

View File

@ -4235,6 +4235,13 @@
'text-decoration': 'underline',
}),
text: (m) => m[1].replace(CONTROL_CHARS$1, ''),
}, {
all: {matcher: /<([a-z]+:\/\/[^>]*)>/g, skip: 0},
attrs: (m) => ({
'href': m[1].replace(CONTROL_CHARS$1, ''),
'text-decoration': 'underline',
}),
text: (m) => m[1].replace(CONTROL_CHARS$1, ''),
},
];

File diff suppressed because one or more lines are too long

View File

@ -4235,6 +4235,13 @@
'text-decoration': 'underline',
}),
text: (m) => m[1].replace(CONTROL_CHARS$1, ''),
}, {
all: {matcher: /<([a-z]+:\/\/[^>]*)>/g, skip: 0},
attrs: (m) => ({
'href': m[1].replace(CONTROL_CHARS$1, ''),
'text-decoration': 'underline',
}),
text: (m) => m[1].replace(CONTROL_CHARS$1, ''),
},
];

View File

@ -70,6 +70,13 @@ const STYLES = [
'text-decoration': 'underline',
}),
text: (m) => m[1].replace(CONTROL_CHARS, ''),
}, {
all: {matcher: /<([a-z]+:\/\/[^>]*)>/g, skip: 0},
attrs: (m) => ({
'href': m[1].replace(CONTROL_CHARS, ''),
'text-decoration': 'underline',
}),
text: (m) => m[1].replace(CONTROL_CHARS, ''),
},
];

View File

@ -239,6 +239,19 @@ describe('Markdown Parser', () => {
]]);
});
it('recognises short link styling', () => {
const formatted = parser('a <http://b> c');
expect(formatted).toEqual([[
{attrs: null, text: 'a '},
{attrs: {
'href': 'http://b',
'text-decoration': 'underline',
}, text: 'http://b'},
{attrs: null, text: ' c'},
]]);
});
it('allows dots around monospace styling', () => {
const formatted = parser('a.`b`.c');