protected override void Write(UIElementRenderer renderer, LiteralInline obj)
        {
            if (obj.Content.IsEmpty)
            {
                return;
            }

            renderer.WriteText(ref obj.Content);
        }
 protected override void Write(UIElementRenderer renderer, LineBreakInline obj)
 {
     if (obj.IsHard)
     {
         renderer.WriteInline(GetClassedElement <Label>("linebreak"));
     }
     else
     {
         // Soft line break.
         renderer.WriteText(" ");
     }
 }
Beispiel #3
0
        protected override void Write(UIElementRenderer renderer, AutolinkInline link)
        {
            var url         = link.Url;
            var lowerScheme = string.Empty;

            if (link.IsEmail)
            {
                url = "mailto:" + url;
            }

            var isValidUri = Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute);

            if (!isValidUri)
            {
                var match = LinkInlineRenderer.SchemeCheck.Match(url);
                if (match.Success)
                {
                    lowerScheme = match.Groups[1].Value.ToLower();
                }
                else
                {
                    lowerScheme = "#";
                }
            }
            else
            {
                var uri = new Uri(url);
                lowerScheme = uri.Scheme.ToLower();
            }

            var linkLabel = GetClassedElement <VisualElement>("link", lowerScheme);

            if (isValidUri)
            {
                linkLabel.RegisterCallback <MouseUpEvent>(evt =>
                {
                    if (LinkInlineRenderer.SchemeLinkHandlers.ContainsKey(lowerScheme))
                    {
                        LinkInlineRenderer.SchemeLinkHandlers[lowerScheme]?.Invoke(url);
                    }
                });
            }
            linkLabel.tooltip = url;

            renderer.Push(linkLabel);
            renderer.WriteText(url);
            renderer.Pop();
        }
        protected override void Write(UIElementRenderer renderer, HtmlEntityInline obj)
        {
            var transcoded = obj.Transcoded;

            renderer.WriteText(ref transcoded);
        }
 protected override void Write(UIElementRenderer renderer, DelimiterInline obj)
 {
     renderer.WriteText(obj.ToLiteral());
     renderer.WriteChildren(obj);
 }