Repository: angular/angular
File: adev/shared-docs/pipeline/shared/marked/renderer.mts (TypeScript)

Code before:
import {Renderer} from 'marked';
import {HighlighterGeneric} from 'shiki';
import {codespanRender} from './transformations/code.mjs';
import {headingRender} from './transformations/heading.mjs';
import {imageRender} from './transformations/image.mjs';
import {linkRender} from './transformations/link.mjs';
import {listRender} from './transformations/list.mjs';
import {tableRender} from './transformations/table.mjs';
import {textRender} from './transformations/text.mjs';

export interface RendererContext {
  /**
   * Path of the markdown file being rendered.
   */
  markdownFilePath?: string;
  /**
   * List of guide routes defined in the application.
   */
  definedRoutes?: string[];
  /**
   * Map of API entries available for linking within the rendered markdown file.
   */
  apiEntries?: Record<string, {moduleName: string; aliases?: string[]}>;
  highlighter: HighlighterGeneric<any, any>;
  headerIds: Map<string, number>;
  /** In the case we want to disable auto-linking because anchor blocks might be incompatible were some code blocks are being rendered */
  disableAutoLinking: boolean;
}

/**
 * Custom renderer for marked that will be used to transform markdown files to HTML
 * files that can be used in the Angular docs.
 */
export class AdevDocsRenderer extends Renderer {
  public context: RendererContext;
  constructor(context: Partial<RendererContext>) {
    super();
    if (context.highlighter === undefined) {
      throw Error(
        'An instance of HighlighterGeneric must be provided to the AdevDocsRenderer at construction',
      );
    }
    context.headerIds = context.headerIds || new Map<string, number>();
    this.context = context as RendererContext;
  }

  defaultRenderer = new Renderer();

  isGuideFile(): boolean {
    return this.context.markdownFilePath?.includes('/content/guide') ?? false;
  }

Review comment (suggestion):
```suggestion
  /** In the case we want to disable auto-linking because anchor blocks might be incompatible where some code blocks are being rendered */
```
Spotted a small typo in this comment :)

Code after:
import {Renderer} from 'marked';
import {HighlighterGeneric} from 'shiki';
import {codespanRender} from './transformations/code.mjs';
import {headingRender} from './transformations/heading.mjs';
import {imageRender} from './transformations/image.mjs';
import {linkRender} from './transformations/link.mjs';
import {listRender} from './transformations/list.mjs';
import {tableRender} from './transformations/table.mjs';
import {textRender} from './transformations/text.mjs';

export interface RendererContext {
  /**
   * Path of the markdown file being rendered.
   */
  markdownFilePath?: string;
  /**
   * List of guide routes defined in the application.
   */
  definedRoutes?: string[];
  /**
   * Map of API entries available for linking within the rendered markdown file.
   */
  apiEntries?: Record<string, {moduleName: string; aliases?: string[]}>;
  highlighter: HighlighterGeneric<any, any>;
  headerIds: Map<string, number>;
  /** In the case we want to disable auto-linking because anchor blocks might be incompatible where some code blocks are being rendered */
  disableAutoLinking: boolean;
}

/**
 * Custom renderer for marked that will be used to transform markdown files to HTML
 * files that can be used in the Angular docs.
 */
export class AdevDocsRenderer extends Renderer {
  public context: RendererContext;
  constructor(context: Partial<RendererContext>) {
    super();
    if (context.highlighter === undefined) {
      throw Error(
        'An instance of HighlighterGeneric must be provided to the AdevDocsRenderer at construction',
      );
    }
    context.headerIds = context.headerIds || new Map<string, number>();
    this.context = context as RendererContext;
  }

  defaultRenderer = new Renderer();

  isGuideFile(): boolean {
    return this.context.markdownFilePath?.includes('/content/guide') ?? false;
  }