fix: Accidental pills in URLs
This commit is contained in:
parent
8de72c869a
commit
44a1bcfd57
|
|
@ -153,6 +153,11 @@ class PillSyntax extends InlineSyntax {
|
|||
|
||||
@override
|
||||
bool onMatch(InlineParser parser, Match match) {
|
||||
if (match.start > 0 &&
|
||||
!RegExp(r'[\s.!?:;\(]').hasMatch(match.input[match.start - 1])) {
|
||||
parser.addNode(Text(match[0]));
|
||||
return true;
|
||||
}
|
||||
final identifier = match[1];
|
||||
final element = Element.text('a', identifier);
|
||||
element.attributes['href'] = 'https://matrix.to/#/${identifier}';
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ void main() {
|
|||
'<a href="https://matrix.to/#/#fox:sorunome.de">#fox:sorunome.de</a>: you all are awesome');
|
||||
expect(markdown('!blah:example.org'),
|
||||
'<a href="https://matrix.to/#/!blah:example.org">!blah:example.org</a>');
|
||||
expect(markdown('https://matrix.to/#/#fox:sorunome.de'),
|
||||
'https://matrix.to/#/#fox:sorunome.de');
|
||||
});
|
||||
test('latex', () {
|
||||
expect(markdown('meep \$\\frac{2}{3}\$'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue