Skip to content

mganss/AutoLink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoLink

Version

AutoLink is a .NET library to perform autolinking on texts, i.e. replace URIs with HTML links.

AutoLink is configurable:

  • Configure URI prefixes (schemes) that trigger recognition of URIs. Default URI prefixes are:
    • http://
    • https://
    • ftp://
    • mailto:
    • www. (will be prepended with http:// in link)
  • Provide your own callback to render HTML based on a URI, e.g. to customize link text or add custom attributes

AutoLink assumes that the input text is raw text, not HTML. If you have HTML, consider using AutoLink as a post-processing step of HtmlSanitizer (example).

AutoLink tries to exclude trailing punctuation (!?,.:;), closing parentheses, and closing brackets from the end of URIs while preserving parentheses that are part of the URI.

Usage

var autolink = new AutoLink();
var text = @"Check it (http://x.org/wiki/Link_(film)).";
var html = autolink.Link(text);
// -> Check it (<a href="http://x.org/wiki/Link_(film)">http://x.org/wiki/Link_(film)</a>).

About

C# Autolinking

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages