angular/adev/shared-docs/pipeline/api-gen/rendering/templates/highlight-ts.tsx
Joey Perrott 7f7a2187a8 refactor(docs-infra): use shiki for highlighting
Use shiki to perform highlighting instead of a postprocessing action

(cherry picked from commit fee79e37d5)
2025-11-21 13:20:49 -05:00

20 lines
753 B
TypeScript

/*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {h} from 'preact';
import {RawHtml} from './raw-html';
import {codeToHtml} from '../../../shared/shiki.mjs';
import {getHighlighterInstance} from '../shiki/shiki.mjs';
/** Component to render a header of the CLI page. */
export function HighlightTypeScript(props: {code: string}) {
const result = codeToHtml(getHighlighterInstance(), props.code, {language: 'typescript'});
const withScrollTrack = result.replace(/^(<pre class="shiki)/, '$1 docs-mini-scroll-track');
return <RawHtml value={withScrollTrack} className="docs-code" />;
}