mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
Do not allow empty inline tags
This commit is contained in:
@ -26,7 +26,10 @@ class InlineTagsProcessor {
|
|||||||
|
|
||||||
var all = tag.split(prefix);
|
var all = tag.split(prefix);
|
||||||
for (var t in all) {
|
for (var t in all) {
|
||||||
tags.add(t.trim());
|
t = t.trim();
|
||||||
|
if (t.isNotEmpty) {
|
||||||
|
tags.add(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,4 +56,84 @@ void main() {
|
|||||||
|
|
||||||
expect(tags, {'one', 'two', 'foo', 'doo'});
|
expect(tags, {'one', 'two', 'foo', 'doo'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Should Ignore headers', () {
|
||||||
|
var body = "# Hi\nHow are you?";
|
||||||
|
|
||||||
|
var p = InlineTagsProcessor(tagPrefixes: {'#', '+', '@'});
|
||||||
|
var tags = p.extractTags(body);
|
||||||
|
|
||||||
|
expect(tags.isEmpty, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Markdown Example', () {
|
||||||
|
var body = """# Markdown Example
|
||||||
|
Markdown allows you to easily include formatted text, images, and even formatted Dart code in your app.
|
||||||
|
|
||||||
|
## Titles
|
||||||
|
|
||||||
|
Setext-style
|
||||||
|
|
||||||
|
This is an H1 ============= This is an H2 -------------
|
||||||
|
|
||||||
|
Atx-style
|
||||||
|
|
||||||
|
# This is an H1 ## This is an H2 ###### This is an H6
|
||||||
|
|
||||||
|
Select the valid headers:
|
||||||
|
|
||||||
|
- [x] # hello
|
||||||
|
- [ ] #hello
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
[Google's Homepage][Google]
|
||||||
|
|
||||||
|
[inline-style](https://www.google.com) [reference-style][Google]
|
||||||
|
|
||||||
|
## Images
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Tables
|
||||||
|
|
||||||
|
|Syntax |Result |
|
||||||
|
|---------------------------------------|-------------------------------------|
|
||||||
|
|*italic 1* |italic 1 |
|
||||||
|
|_italic 2_ | italic 2 |
|
||||||
|
|**bold 1** |bold 1 |
|
||||||
|
|__bold 2__ |bold 2 |
|
||||||
|
|This is a ~~strikethrough~~ |This is a strikethrough |
|
||||||
|
|***italic bold 1*** |italic bold 1 |
|
||||||
|
|___italic bold 2___ |italic bold 2 |
|
||||||
|
|***~~italic bold strikethrough 1~~***|***italic bold strikethrough 1***|
|
||||||
|
|~~***italic bold strikethrough 2***~~|italic bold strikethrough 2|
|
||||||
|
|
||||||
|
## Styling
|
||||||
|
Style text as italic, bold, strikethrough, or inline code.
|
||||||
|
|
||||||
|
- Use bulleted lists
|
||||||
|
- To better clarify
|
||||||
|
- Your points
|
||||||
|
|
||||||
|
## Code blocks
|
||||||
|
Formatted Dart code looks really pretty too:
|
||||||
|
|
||||||
|
void main() { runApp(MaterialApp( home: Scaffold( body: Markdown(data: markdownData), ), )); }
|
||||||
|
|
||||||
|
## Markdown widget
|
||||||
|
|
||||||
|
This is an example of how to create your own Markdown widget:
|
||||||
|
|
||||||
|
Markdown(data: 'Hello world!');
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
[Google]: https://www.google.com/""";
|
||||||
|
|
||||||
|
var p = InlineTagsProcessor(tagPrefixes: {'#', '+', '@'});
|
||||||
|
var tags = p.extractTags(body);
|
||||||
|
|
||||||
|
expect(tags, {'hello'});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user