<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using Markdig.Syntax.Inlines;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Overlays;

namespace osu.Game.Graphics.Containers.Markdown
{
    public class OsuMarkdownLinkText : MarkdownLinkText
    {
        [Resolved]
        private OverlayColourProvider colourProvider { get; set; }

        private SpriteText spriteText;

        public OsuMarkdownLinkText(string text, LinkInline linkInline)
            : base(text, linkInline)
        {
        }

        [BackgroundDependencyLoader]
        private void load()
        {
            spriteText.Colour = colourProvider.Light2;
        }

        public override SpriteText CreateSpriteText()
        {
            return spriteText = base.CreateSpriteText();
        }

        protected override bool OnHover(HoverEvent e)
        {
            spriteText.Colour = colourProvider.Light1;
            return base.OnHover(e);
        }

        protected override void OnHoverLost(HoverLostEvent e)
        {
            spriteText.Colour = colourProvider.Light2;
            base.OnHoverLost(e);
        }
    }
}<commit_msg>use drawable link compiler in markdown link<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using Markdig.Syntax.Inlines;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Game.Online.Chat;
using osu.Game.Overlays;

namespace osu.Game.Graphics.Containers.Markdown
{
    public class OsuMarkdownLinkText : MarkdownLinkText
    {
        [Resolved(canBeNull: true)]
        private OsuGame game { get; set; }

        protected string Text;
        protected string Title;

        public OsuMarkdownLinkText(string text, LinkInline linkInline)
            : base(text, linkInline)
        {
            Text = text;
            Title = linkInline.Title;
        }

        [BackgroundDependencyLoader]
        private void load(OverlayColourProvider colourProvider)
        {
            var text = CreateSpriteText().With(t => t.Text = Text);
            InternalChildren = new Drawable[]
            {
                text,
                new OsuMarkdownLinkCompiler(new[] { text })
                {
                    RelativeSizeAxes = Axes.Both,
                    Action = OnLinkPressed,
                    TooltipText = Title ?? Url,
                }
            };
        }

        protected override void OnLinkPressed() => game?.HandleLink(Url);

        private class OsuMarkdownLinkCompiler : DrawableLinkCompiler
        {
            public OsuMarkdownLinkCompiler(IEnumerable<Drawable> parts)
                : base(parts)
            {
            }

            [BackgroundDependencyLoader]
            private void load(OverlayColourProvider colourProvider)
            {
                IdleColour = colourProvider.Light2;
                HoverColour = colourProvider.Light1;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07671398369072788, 'fraction_numerical': 0.0015101177891875567, 'mean_word_length': 2.0752089136490253, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, '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': '136031', 'n_tokens_mistral': 908, 'n_tokens_neox': 885, 'n_words': 208}