InsertLinks Class
Replaces occurrences of specified strings with HTML links.
Namespace
Statiq.Core
Interfaces
Base Types
graph BT Type-->Base0["ParallelModule"] click Base0 "/api/Statiq.Common/ParallelModule" Base0-->Base1["Module"] click Base1 "/api/Statiq.Common/Module" Base1-->Base2["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type-.->Interface1["IParallelModule"] click Interface1 "/api/Statiq.Common/IParallelModule" Type["InsertLinks"] class Type type-node

Syntax

public class InsertLinks : ParallelModule, IModule, IParallelModule

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
InsertLinks() Creates the module without any initial mappings. Use AddLink(...) to add mappings with fluent methods.
InsertLinks(Config<IDictionary<string, string>>) Specifies a dictionary of link mappings given an IDocument and 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.

Properties

Name Property Type Summary
Parallel bool
Indicates whether documents will be processed by this module in parallel.
Inherited from ParallelModule

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
Inherited from ParallelModule
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
WithEndWordSeparators(char[]) InsertLinks
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) InsertLinks
Adds an additional link to the mapping. This can be used whether or not you specify a mapping in the constructor.
WithMatchOnlyWholeWord(bool) InsertLinks
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) InsertLinks
Allows you to specify an alternate query selector.
WithStartWordSeparators(char[]) InsertLinks
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[]) InsertLinks
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.

Extension Methods