Skip to content

Correctly handle HTML <pre> elements #320

Open
@fynnfeldpausch

Description

@fynnfeldpausch

While Autolinker correctly handles <a> tags in the input string, it does not handle HTML <pre> elements correctly and will apply auto-linking within those texts.

Expected
Autolinker.link(<pre>https://www.test.com</pre>) to be <pre>https://www.test.com</pre>.

Actual
Autolinker.link(<pre>https://www.test.com</pre>) is <pre><a href="https://www.test.com" target="_blank" rel="noopener noreferrer">test.com</a></pre>.

Activity

fynnfeldpausch

fynnfeldpausch commented on May 12, 2020

@fynnfeldpausch
Author

Ideally, This would be configurable since I also would like to avoid auto-linking in <code> elements

gphaydon

gphaydon commented on Jul 29, 2020

@gphaydon

Is there anyway to prevent Autolinker from touching <pre> elements? I was wondering if, given no other config option, if replaceFn could be used to switch it off when the ancestor tag is a pre.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @fynnfeldpausch@gphaydon

        Issue actions

          Correctly handle HTML <pre> elements · Issue #320 · gregjacobs/Autolinker.js