pd4d10 / git-touch

An open-source app for GitHub, GitLab, Bitbucket, Gitea, and Gitee(码云), built with Flutter
Apache License 2.0
1.57k stars 138 forks source link

Link to user profile in markdown #87

Open shreyas1599 opened 4 years ago

shreyas1599 commented 4 years ago

Consider comment_item. I'm trying to add a link to the profile. For example, @shreyas1599 should link to my profile. I used a simple regex to do this:

body.replaceAllMapped(new RegExp(r"@[^\s]+"), (match) { return "[${match[0]}](https://github.com/${match[0] })";

A couple of questions:

@pd4d10 I'd like your opinion on this. Thanks.

pd4d10 commented 4 years ago

If the purpose is to replace @somebody with a link, it seems not enough to just tweak the onTapLink method.

We should add a plugin to flutter_markdown to identify the @somebody syntax, then turn it into a link.

pd4d10 commented 4 years ago

But in router.dart you've added a TODO: /github.

Yeah, it is a legacy todo. We should open an issue for this: Add /github prefix to GitHub related screens, just like other platforms.

pd4d10 commented 4 years ago

body.replaceAllMapped(new RegExp(r"@[^\s]+"), (match) { return "[${match[0]}](https://github.com/${match[0] })";

Oh, I missed this replacement process. This might also work but it seems more common to write a plugin for flutter_markdown

shreyas1599 commented 4 years ago

Sorry, I don't exactly understand. I've never written one before. By plugin do you mean, I use flutter_markdown and create a package that identifies the @ symbol and converts it into a link? Can you give an example of writing a plugin for a package?

pd4d10 commented 4 years ago

MarkdownBody has a property named extensionSet: https://pub.dev/documentation/flutter_markdown/latest/flutter_markdown/MarkdownBody-class.html

For examples see: https://pub.dev/packages/markdown#syntax-extensions

pd4d10 commented 4 years ago

There is also a legacy issue related to this: Rendering <img> tag correctly. <img> seems to be frequently used.