This site provides a machine-readable index at /llms.txt.

Skip to main content Skip to navigation

XrefHtmlRewriter Pennington.Infrastructure

Resolves xref: cross-reference links on the shared response document. Delegates both phases to XrefResolvingService. Runs first in the HTML rewriting pipeline so the canonical paths it emits are available to later locale and base-URL rewriters.

Properties

Order int
Sort order within the HTML rewriting pipeline. Rewriters run in ascending Order. Xref resolution at 10, locale prefixing at 20, base-URL prefixing at 30 — the outside-in order that was previously expressed across separate IResponseProcessors.

Constructors

.ctor

#
public XrefHtmlRewriter(XrefResolvingService service);

Initializes the rewriter with the xref resolving service.

Parameters

service XrefResolvingService

Methods

ApplyAsync

#
public async Task ApplyAsync(IDocument document, HttpContext context);

Mutate the shared parsed document. The orchestrator serializes it once after every rewriter has run.

Parameters

document IDocument
context HttpContext

Returns

Task

PreParseAsync

#
public Task<string> PreParseAsync(string html, HttpContext context);

Regex / string pre-pass over the raw HTML before AngleSharp parses it. Exists for constructs that are not valid HTML (such as raw <xref:uid> tags) and therefore must be substituted out before the parser runs.

Default: pass-through. Rewriters that only touch the DOM should not override this.

Parameters

html string
context HttpContext

Returns

Task<string>

ShouldApply

#
public bool ShouldApply(HttpContext context);

Cheap gate checked before parsing. Return false to skip both PreParseAsync and ApplyAsync for this response. If every rewriter returns false, the orchestrator skips parsing entirely.

Parameters

context HttpContext

Returns

bool

Pennington.Infrastructure.XrefHtmlRewriter

namespace Pennington.Infrastructure;

/// Resolves xref: cross-reference links on the shared response document. Delegates both phases to XrefResolvingService. Runs first in the HTML rewriting pipeline so the canonical paths it emits are available to later locale and base-URL rewriters.
public class XrefHtmlRewriter
{
    /// Initializes the rewriter with the xref resolving service.
    
public XrefHtmlRewriter(XrefResolvingService service);
/// Mutate the shared parsed document. The orchestrator serializes it once after every rewriter has run.
public async Task ApplyAsync(IDocument document, HttpContext context);
/// Sort order within the HTML rewriting pipeline. Rewriters run in ascending Order. Xref resolution at 10, locale prefixing at 20, base-URL prefixing at 30 — the outside-in order that was previously expressed across separate IResponseProcessors.
public int Order => 10;
/// Regex / string pre-pass over the raw HTML before AngleSharp parses it. Exists for constructs that are not valid HTML (such as raw <xref:uid> tags) and therefore must be substituted out before the parser runs. Default: pass-through. Rewriters that only touch the DOM should not override this.
public Task<string> PreParseAsync(string html, HttpContext context);
/// Cheap gate checked before parsing. Return false to skip both PreParseAsync and ApplyAsync for this response. If every rewriter returns false, the orchestrator skips parsing entirely.
public bool ShouldApply(HttpContext context);
}