ArtificialSenseDocs

Docs / Utilities

Syntax highlighter utilities

Lightweight tokenizer that returns HTML spans for TypeScript and HTML code samples from @artificialsenselabs/ui.

Live demo: run nx serve showcase and open /components/syntax-highlighter (port 4202).

Overview

Category: Utility. Import: import { highlight, tokenize, escapeForCode } from '@artificialsenselabs/ui';

const html = highlight(source, 'typescript');
// bind with DomSanitizer.bypassSecurityTrustHtml in demo/docs only

Security

  • highlight() escapes plain text and wraps tokens in <span> elements.
  • Only bind trusted source code โ€” never pass user-provided strings without sanitization review.
  • Use DomSanitizer.bypassSecurityTrustHtml only in controlled demo or docs contexts.