Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html generated links have nofollow? #756

Closed
NetTecture opened this issue Nov 29, 2023 · 3 comments
Closed

Html generated links have nofollow? #756

NetTecture opened this issue Nov 29, 2023 · 3 comments
Labels

Comments

@NetTecture
Copy link

Any reference how to control that? Would like to not have nofollow for links that are - well - internal (and some external).

@xoofx xoofx added the question label Nov 30, 2023
@xoofx
Copy link
Owner

xoofx commented Nov 30, 2023

I don't think this is enabled by default. How do you create your MarkdownPipelineBuilder?

@NetTecture
Copy link
Author

static readonly MarkdownPipeline pipeline = new MarkdownPipelineBuilder()
    .UseAdvancedExtensions()
    .UseAutoLinks()
    .UseBootstrap()
    .Build();

public static string RenderToHtml(string text, bool inline = false)
{
    if (inline)
    {
        return RenderToHtmlInline(text);
    }
    return Markdown.ToHtml(text, pipeline);
}

public static string RenderToHtmlInline(string text)
{
    var document = Markdown.Parse(text, pipeline);

    StringWriter writer = new();
    var renderer = new HtmlRenderer(writer)
    {
        ImplicitParagraph = true // note this change
    };
    pipeline.Setup(renderer);

    renderer.Render(document); // using the renderer directly
    writer.Flush();
    string html = writer.ToString();
    html = html.Replace(" rel=\"nofollow\"", "");
    return html;
}

This is literally the complete code for my render pipeline at the moment.

@xoofx xoofx added invalid and removed question labels Dec 12, 2023
@xoofx
Copy link
Owner

xoofx commented Dec 12, 2023

I cannot see any usage of nofollow in the current codebase. I just created an exe with the latest Markdig 0.33 and I'm getting the correct output:

internal class Program
{
    static void Main(string[] args)
    {
        MarkdownPipeline pipeline = new MarkdownPipelineBuilder()
            .UseAdvancedExtensions()
            .UseAutoLinks()
            .UseBootstrap()
            .Build();

        var document = Markdown.Parse("Hello with a link [Hello](https://google.com)", pipeline);
        var html = document.ToHtml(pipeline);

        Console.WriteLine(html);
    }
}

Outputs:

<p>Hello with a link <a href="https://google.com">Hello</a></p>

So closing this bug as invalid because it is not reproduced.

@xoofx xoofx closed this as completed Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants