Open link in new window (target="_blank")

I have…

  • a query to make the link to open in new tab

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x ] Documentation issue or request

Current behavior

I want the link to be opened in new tab.I am using link in schema for my field and using Markdown as editor

Expected behavior

Minimal reproduction of the problem

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Hi,

Markdown does not support it. You have to implement it in your renderer where you convert the Markdown to HTML.

For example. For the Squidex website I use C# and markdig (https://github.com/xoofx/markdig):

I have a custom link renderer that converts link to github gist to scripts:

public sealed class CustomAutolinkRenderer : AutolinkInlineRenderer
    {
        protected override void Write(HtmlRenderer renderer, AutolinkInline obj)
        {
            var url = obj.Url;

            if (url.StartsWith("https://gist.github.com", StringComparison.OrdinalIgnoreCase))
            {
                renderer.Write($"<script src=\"{url}.js\"></script>");

                return;
            }

            base.Write(renderer, obj);
        }
    }

I convert markdown to HTML using this extension method:

public static class MarkdownRenderer
    {
        private static readonly MarkdownPipeline Pipeline = new MarkdownPipelineBuilder().UseAutoLinks().Build();

        public static string ToHtml(string markdown)
        {
            if (string.IsNullOrWhiteSpace(markdown))
            {
                return string.Empty;
            }

            var document = Markdown.Parse(markdown, Pipeline);

            using (var writer = new StringWriter())
            {
                var renderer = new HtmlRenderer(writer);
                renderer.ObjectRenderers.RemoveAll(x => x is AutolinkInlineRenderer);
                renderer.ObjectRenderers.Add(new CustomAutolinkRenderer());

                Pipeline.Setup(renderer);

                renderer.Render(document);

                writer.Flush();

                return writer.ToString();
            }
        }
    }

If you use another programming language or library you have to find a solution yourself, but I wanted to point you to the idea.