This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

IShortcode Pennington.Markdown.Shortcodes

Handler for a named shortcode invocation expanded before Markdig parsing. Implementations are registered as DI services and dispatched by Name (case-insensitive). The string returned by ExecuteAsync is spliced into the markdown source and then parsed as markdown — return raw HTML when the output should bypass markdown processing (use HTML block syntax so Markdig leaves it intact).

Properties

Name string
Case-insensitive name used to dispatch <?# Name ... ?> invocations.

Methods

ExecuteAsync

#
public Task<string> ExecuteAsync(ShortcodeInvocation invocation, ShortcodeContext context, CancellationToken cancellationToken)

Produces the replacement text for one invocation. invocation carries the parsed arguments and inline content (null for self-closing tags); context carries the host page's route and metadata.

Parameters

invocation ShortcodeInvocation
context ShortcodeContext
cancellationToken CancellationToken

Returns

Task<string>

Pennington.Markdown.Shortcodes.IShortcode

namespace Pennington.Markdown.Shortcodes;

/// Handler for a named shortcode invocation expanded before Markdig parsing. Implementations are registered as DI services and dispatched by Name (case-insensitive). The string returned by ExecuteAsync is spliced into the markdown source and then parsed as markdown — return raw HTML when the output should bypass markdown processing (use HTML block syntax so Markdig leaves it intact).
public interface IShortcode
{
    /// Produces the replacement text for one invocation. invocation carries the parsed arguments and inline content (null for self-closing tags); context carries the host page's route and metadata.
    
public Task<string> ExecuteAsync(ShortcodeInvocation invocation, ShortcodeContext context, CancellationToken cancellationToken)
; /// Case-insensitive name used to dispatch <?# Name ... ?> invocations.
public string Name { get; }
}