Improve inline tags regexp

Fixes #265
This commit is contained in:
Vishesh Handa
2020-10-05 11:43:18 +02:00
parent 68c6fe470d
commit 1a74955e99
3 changed files with 15 additions and 1 deletions

View File

@ -6,6 +6,7 @@
bugs:
- text: "Dark Theme: Render checkboxes in a lighter color"
- text: "Fix Relative Parent links not working - #256"
- test: "Improve inline tags regex - #265"
- version: "1.70"
date: 2020-09-16

View File

@ -15,7 +15,7 @@ class InlineTagsProcessor {
p = '\\+';
}
var regexp = RegExp(r'(^|\s)' + p + r'([^ ]+)(\s|$)');
var regexp = RegExp(r'(^|\s)' + p + r'([^\s]+)(\s|$)');
var matches = regexp.allMatches(text);
for (var match in matches) {
var tag = match.group(2);

View File

@ -136,4 +136,17 @@ Enjoy!
expect(tags, {'hello'});
});
test("Handles Spaces", () {
var body = """# DateTimeOffset
#csharp
Provides a combined #structure\tof `DateTime` with an `Offset` property defining a deviation from UTC. It doesn't associate a time zone with the offset.
""";
var p = InlineTagsProcessor(tagPrefixes: {'#', '+', '@'});
var tags = p.extractTags(body);
expect(tags, {'csharp', 'structure'});
});
}