mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
81b30dcef0
To increase the ease of development we are moving @angular/docs into the adev directory within this repo. While we are doing this to improve our development experience in the short term, efforts are also in place to maintain a division between this @angular/docs (shared) code and adev itself, so that it can be extracted back out in the future when components is ready to leverage it as well. PR Close #57132
29 lines
886 B
TypeScript
29 lines
886 B
TypeScript
import {Token} from 'marked';
|
|
import {DocsCodeToken} from './extensions/docs-code/docs-code';
|
|
|
|
/**
|
|
* Describe a HANDLE_MERMAID value which esbuild will use at build time to determine if the mermaid
|
|
* related code should be included in the bundle.
|
|
* THIS VALUE IS NOT AVAILABLE AT RUNTIME.
|
|
*/
|
|
export declare const HANDLE_MERMAID: boolean;
|
|
|
|
/** Type guard for if a provided token is the DocsCodeToken. */
|
|
function isDocsCodeToken(token: Token): token is DocsCodeToken {
|
|
return !!(token as DocsCodeToken).language;
|
|
}
|
|
|
|
/**
|
|
* Handle the provided token based on the token itself replacing its content/data in place
|
|
* as appropriate.
|
|
*/
|
|
export async function walkTokens(token: Token): Promise<void> {
|
|
if (!isDocsCodeToken(token) || token.language !== 'mermaid') {
|
|
return;
|
|
}
|
|
|
|
if (HANDLE_MERMAID) {
|
|
return (await import('./mermaid')).processMermaidCodeBlock(token);
|
|
}
|
|
}
|