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
Orderint- 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 separateIResponseProcessors.
Constructors
.ctor
#public XrefHtmlRewriter(XrefResolvingService service);Initializes the rewriter with the xref resolving service.
Parameters
serviceXrefResolvingService
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
documentIDocumentcontextHttpContext
Returns
TaskPreParseAsync
#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
htmlstringcontextHttpContext
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
contextHttpContext
Returns
boolPennington.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);
}