AutoLink Class

Summary

Replaces occurrences of specified strings with HTML links.
Assembly
Wyam.Html.dll
Namespace
Wyam.Html
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type["AutoLink"] class Type type-node

Syntax

public class AutoLink : IModule

Remarks

This module is smart enough to only look in specified HTML elements (p by default). You can supply an alternate query selector to narrow the search scope to different container elements or to those elements that contain (or don't contain) a CSS class, etc. It also won't generate an HTML link if the replacement text is already found in another link.

Note that because this module parses the document content as standards-compliant HTML and outputs the formatted post-parsed DOM, you should only place this module after all other template processing has been performed.

Constructors

Name Summary
AutoLink() Creates the module without any initial mappings. Use AddLink(...) to add mappings with fluent methods.
AutoLink(ContextConfig) Specifies a dictionary of link mappings given an Wyam.Common.Execution.IExecutionContext. The return value is expected to be a IDictionary<string, string>. The keys specify strings to search for in the HTML content and the values specify what should be placed in the href attribute. This uses the same link mappings for all input documents.
AutoLink(DocumentConfig) Specifies a dictionary of link mappings given an AngleSharp.Dom.IDocument and Wyam.Common.Execution.IExecutionContext. The return value is expected to be a IDictionary<string, string>. The keys specify strings to search for in the HTML content and the values specify what should be placed in the href attribute. This allows you to specify a different mapping for each input document.
AutoLink(IDictionary<string, string>) Specifies a dictionary of link mappings. The keys specify strings to search for in the HTML content and the values specify what should be placed in the href attribute. This uses the same link mappings for all input documents.

Methods

Name Value Summary
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
WithEndWordSeparators(char[]) AutoLink
Adds additional end word separator characters when limiting matches to whole words only. These additional characters are in addition to the default of splitting words at white space.
WithLink(string, string) AutoLink
Adds an additional link to the mapping. This can be used whether or not you specify a mapping in the constructor.
WithMatchOnlyWholeWord(bool) AutoLink
Forces the string search to only consider whole words (it will not add a link in the middle of a word). By default whole words are determined by testing for white space.
WithQuerySelector(string) AutoLink
Allows you to specify an alternate query selector.
WithStartWordSeparators(char[]) AutoLink
Adds additional start word separator characters when limiting matches to whole words only. These additional characters are in addition to the default of splitting words at white space.
WithWordSeparators(char[]) AutoLink
Adds additional word separator characters when limiting matches to whole words only. These additional characters are in addition to the default of splitting words at white space.
GitHub