more
or excerpt
)
contained within an HTML comment (<!--more-->
). If a separator comment isn't found, the module
will fallback to looking for the first occurrence of a specific HTML element (p
paragraph elements by default)
and will use the outer HTML content. In both cases, the excerpt is placed in metadata with a key of Excerpt
.
The content of the original input document is left unchanged.
Package
#n Wyam.Html
Usage
-
Excerpt()
Creates the module with the default query selector of
p
. -
Excerpt(string querySelector)
Specifies an alternate query selector for the content.
querySelector
The query selector to use.
-
Excerpt(string[] separators)
Specifies alternate separators to be used in an HTML comment. Setting this to
null
will disable looking for separators and rely only on the query selector.separators
The excerpt separators.
Fluent Methods
Chain these methods together after the constructor to modify behavior.
-
WithMetadataKey(string metadataKey)
Allows you to specify an alternate metadata key.
metadataKey
The metadata key to store the excerpt in.
-
WithOuterHtml(bool outerHtml)
Controls whether the inner HTML (not including the containing element's HTML) or outer HTML (including the containing element's HTML) of the first result from the query selector is added to metadata. The default is true, which gets the outer HTML content. This setting has no effect if a separator comment is found.
outerHtml
If set to
true
, outer HTML will be stored.
-
WithQuerySelector(string querySelector)
Allows you to specify an alternate query selector. If a separator comment was found then the query selector will be used to determine which elements prior to the separator the excerpt should be taken from.
querySelector
The query selector to use.
-
WithSeparators(string[] separators)
Specifies alternate separators to be used in an HTML comment. Setting this to
null
will disable looking for separators and rely only on the query selector.separators
The excerpt separators.
Output Metadata
The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.
-
HtmlKeys.Excerpt
:System.String
Contains the content of the first result from the query selector (unless an alternate metadata key is specified).