<commit_before>import 'package:angular2/angular2.dart';
import 'package:angular2/core.dart' show Pipe;
import 'package:markdown/markdown.dart';
import 'package:slack_history_keeper_frontend/services/slack_service.dart';
import 'package:slack_history_keeper_shared/src/models.dart';

const parserBindings = const [MessageParser, MentionSyntax, EmoticonSyntax];

@Pipe(name: 'messageParser', pure: true)
@Injectable()
class MessageParser implements PipeTransform {
  List<TextSyntax> inlineSyntaxes = [];

  MessageParser(MentionSyntax mentionSyntax, EmoticonSyntax emoticonSyntax) {
    inlineSyntaxes = [mentionSyntax, emoticonSyntax];
  }

  @override
  String transform(String message, List args) {
    return markdownToHtml(message, inlineSyntaxes: inlineSyntaxes);
  }
}

@Injectable()
class MentionSyntax extends InlineSyntax {
  final SlackService slackService;

  MentionSyntax(this.slackService) : super(r'<@([A-Z0-9]{9})(?:\|[a-z]+)?>');

  @override
  bool onMatch(InlineParser parser, Match match) {
    var userId = match.group(1);
    var user = slackService.getUserFromId(userId);
    var anchor = new Element.text('a', '@' + user.name);
    anchor.attributes['href'] = "http://google.ca";

    parser.addNode(anchor);
    return true;
  }
}

@Injectable()
class EmoticonSyntax extends InlineSyntax {
  static const emojisUrl =
      'https://raw.githubusercontent.com/arvida/emoji-cheat-sheet.com/master/public/graphics/emojis';
  final SlackService slackService;

  EmoticonSyntax(this.slackService) : super(r':([a-zA-Z0-9_]+):');

  @override
  bool onMatch(InlineParser parser, Match match) {
    var name = match.group(1);
    var emoticon = slackService.getEmoticonFromName(name);

    while (emoticon != null && emoticon.url.startsWith('alias:')) {
      name = emoticon.url.substring(6);
      emoticon = slackService.getEmoticonFromName(name);
    }

    var img = createEmoticonImage(emoticon, name);
    parser.addNode(img);
<commit_msg>remove anchor on mentions<commit_after>import 'package:angular2/angular2.dart';
import 'package:angular2/core.dart' show Pipe;
import 'package:markdown/markdown.dart';
import 'package:slack_history_keeper_frontend/services/slack_service.dart';
import 'package:slack_history_keeper_shared/src/models.dart';

const parserBindings = const [MessageParser, MentionSyntax, EmoticonSyntax];

@Pipe(name: 'messageParser', pure: true)
@Injectable()
class MessageParser implements PipeTransform {
  List<TextSyntax> inlineSyntaxes = [];

  MessageParser(MentionSyntax mentionSyntax, EmoticonSyntax emoticonSyntax) {
    inlineSyntaxes = [mentionSyntax, emoticonSyntax];
  }

  @override
  String transform(String message, List args) {
    return markdownToHtml(message, inlineSyntaxes: inlineSyntaxes);
  }
}

@Injectable()
class MentionSyntax extends InlineSyntax {
  final SlackService slackService;

  MentionSyntax(this.slackService) : super(r'<@([A-Z0-9]{9})(?:\|[a-z]+)?>');

  @override
  bool onMatch(InlineParser parser, Match match) {
    var userId = match.group(1);
    var user = slackService.getUserFromId(userId);
    var anchor = new Element.text('strong', '@' + user.name);

    parser.addNode(anchor);
    return true;
  }
}

@Injectable()
class EmoticonSyntax extends InlineSyntax {
  static const emojisUrl =
      'https://raw.githubusercontent.com/arvida/emoji-cheat-sheet.com/master/public/graphics/emojis';
  final SlackService slackService;

  EmoticonSyntax(this.slackService) : super(r':([a-zA-Z0-9_]+):');

  @override
  bool onMatch(InlineParser parser, Match match) {
    var name = match.group(1);
    var emoticon = slackService.getEmoticonFromName(name);

    while (emoticon != null && emoticon.url.startsWith('alias:')) {
      name = emoticon.url.substring(6);
      emoticon = slackService.getEmoticonFromName(name);
    }

    var img = createEmoticonImage(emoticon, name);
    parser.addNode(img);

{'fraction_non_alphanumeric': 0.12882489071740807, 'fraction_numerical': 0.00565698122910774, 'mean_word_length': 5.125984251968504, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '661072', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1263, 'n_words': 235}