Rename MetaLinkSyntax to WikiLinkSyntax

This commit is contained in:
Vishesh Handa
2020-06-12 13:50:54 +02:00
parent ede78f6019
commit 5e557ef6c3
3 changed files with 7 additions and 7 deletions

View File

@ -55,8 +55,8 @@ class LinkExtractor implements md.NodeVisitor {
}
if (tag == 'wikiLink') {
var value = el.attributes['value'];
var link = Link(term: value, filePath: null);
var term = el.attributes['term'];
var link = Link(term: term, filePath: null);
links.add(link);
return;
}
@ -70,15 +70,15 @@ class LinkExtractor implements md.NodeVisitor {
}
}
class MetaLinkSyntax extends md.InlineSyntax {
class WikiLinkSyntax extends md.InlineSyntax {
static final String _pattern = '\\[\\[([^\\[\\]]+)\\]\\]';
MetaLinkSyntax() : super(_pattern);
WikiLinkSyntax() : super(_pattern);
@override
bool onMatch(md.InlineParser parser, Match match) {
md.Element el = md.Element.withTag('wikiLink');
el.attributes['value'] = '${match[1].trim()}';
el.attributes['term'] = '${match[1].trim()}';
parser.addNode(el);
return true;
}

View File

@ -458,7 +458,7 @@ class Note with NotesNotifier {
final doc = md.Document(
encodeHtml: false,
extensionSet: md.ExtensionSet.gitHubFlavored,
inlineSyntaxes: [MetaLinkSyntax()],
inlineSyntaxes: [WikiLinkSyntax()],
);
var lines = body.replaceAll('\r\n', '\n').split('\n');

View File

@ -185,7 +185,7 @@ class NoteSnippet extends StatelessWidget {
}
List<TextSpan> _extraMetaLinks(TextStyle textStyle, String line) {
var regExp = MetaLinkSyntax().pattern;
var regExp = WikiLinkSyntax().pattern;
var spans = <TextSpan>[];