[GH-ISSUE #87] Link to user profile in markdown #2511

Open
opened 2026-05-03 02:14:42 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @shreyas1599 on GitHub (May 12, 2020).
Original GitHub issue: https://github.com/pd4d10/git-touch/issues/87

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:

  • Should I place this in markdown_view.dart or leave it in comment_item.dart itself?
  • Also in mardown_view.dart I see you've used a github prefix. For now, I could just push the relative path.
  • But in router.dart you've added a TODO: /github.
  • So should I try and replace all the existing github routes to use the prefix github or just push the relative path for now? Something like this:
    return Provider.of<ThemeModel>(context).push(context, "/${m['login']}");
  • I could first open a PR to change all the existing routes to use /github and then implement the above.

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

Originally created by @shreyas1599 on GitHub (May 12, 2020). Original GitHub issue: https://github.com/pd4d10/git-touch/issues/87 Consider [comment_item](https://github.com/git-touch/git-touch/blob/master/lib/widgets/comment_item.dart#L186). 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: - Should I place this in `markdown_view.dart` or leave it in `comment_item.dart` itself? - Also in [mardown_view.dart](https://github.com/git-touch/git-touch/blob/master/lib/widgets/markdown_view.dart#L46-L68) I see you've used a `github` prefix. For now, I could just push the relative path. - But in `router.dart` you've added a [TODO: /github](https://github.com/git-touch/git-touch/blob/master/lib/router.dart#L65). - So should I try and replace all the existing github routes to use the prefix `github` or just push the relative path for now? Something like this: `return Provider.of<ThemeModel>(context).push(context, "/${m['login']}");` - I could first open a PR to change all the existing routes to use `/github` and then implement the above. @pd4d10 I'd like your opinion on this. Thanks.
Author
Owner

@pd4d10 commented on GitHub (May 12, 2020):

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.

<!-- gh-comment-id:627252635 --> @pd4d10 commented on GitHub (May 12, 2020): If the purpose is to replace `@somebody` with a link, it seems not enough to just tweak the [onTapLink](https://github.com/git-touch/git-touch/blob/master/lib/widgets/markdown_view.dart#L31) method. We should add a plugin to [flutter_markdown](https://github.com/flutter/flutter_markdown) to identify the `@somebody` syntax, then turn it into a link.
Author
Owner

@pd4d10 commented on GitHub (May 12, 2020):

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.

<!-- gh-comment-id:627253446 --> @pd4d10 commented on GitHub (May 12, 2020): > 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.
Author
Owner

@pd4d10 commented on GitHub (May 12, 2020):

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

<!-- gh-comment-id:627254170 --> @pd4d10 commented on GitHub (May 12, 2020): > 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
Author
Owner

@shreyas1599 commented on GitHub (May 16, 2020):

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?

<!-- gh-comment-id:629666539 --> @shreyas1599 commented on GitHub (May 16, 2020): 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?
Author
Owner

@pd4d10 commented on GitHub (May 17, 2020):

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

<!-- gh-comment-id:629740409 --> @pd4d10 commented on GitHub (May 17, 2020): `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
Author
Owner

@pd4d10 commented on GitHub (May 17, 2020):

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

<!-- gh-comment-id:629740678 --> @pd4d10 commented on GitHub (May 17, 2020): There is also a legacy issue related to this: Rendering `<img>` tag correctly. `<img>` seems to be frequently used.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/git-touch#2511