Skip to content

API reference

Every exported provider, component, directive and function.

Every public export, by package.

@blasdoc/core

Parsing

ts
import { parseBlasdoc, createBlasdocParser, BlasdocParserCache } from '@blasdoc/core';
 
parseBlasdoc(markdown, options?);      // one-shot
createBlasdocParser(options?);         // reusable
new BlasdocParserCache(parser, { limit? });

BlasdocParseResult carries document, source, diagnostics, frontmatter and settings.

Parse options

OptionMeaning
isComponentName(name)decides which tags are components; default is "contains a dash"
htmlPolicythe allow-list of tags and attributes

The IR

ts
import type {
  BlasdocNode, BlasdocDocumentNode, BlasdocComponentNode,
  BlasdocElementNode, BlasdocHeadingNode, BlasdocPosition,
} from '@blasdoc/core';

A component node keeps the four channels apart: attributes, bindings, events, twoWayBindings, each entry carrying rawName, quote and a cross-channel order.

Outline

ts
import { blasdocHeadings, blasdocSlug, blasdocText } from '@blasdoc/core';

Source

ts
import {
  sliceSource, sliceChildrenSource,
  renderAngularSource, renderMarkdownSource,
} from '@blasdoc/core';

Expressions

ts
import { parseExpression, evaluateExpression } from '@blasdoc/core';

Build (@blasdoc/core/build)

ts
import {
  blasdoc,                      // the Vite/Rollup plugin
  transformAngularPage,
  editorAngularPage,
  installAngularPageTransform,
} from '@blasdoc/core/build';

@blasdoc/angular

Providers

ts
provideBlasdoc({ components?, context?, parseOptions? });
provideBlasdocHydration();

Pages

ts
import {
  BlasdocPage,             // the base class
  blasdocPage,             // the configured base class
  blasdocPageInit,         // emitted by the build transform
  blasdocPageDiagnostics,
  blasdocPageHeadings,
} from '@blasdoc/angular';

Rendering a string

html
<blasdoc-content [source]="markdown" [context]="ctx" (diagnostics)="…" />
ts
import { BlasdocContentComponent, BlasdocDocumentComponent, BlasdocRenderer } from '@blasdoc/angular';

Registry

ts
import { BlasdocComponentRegistry, BLASDOC_COMPONENTS, normaliseComponents } from '@blasdoc/angular';

Tokens

TokenGives
BLASDOC_NODEthe IR node a component was created from
BLASDOC_DOCUMENT_CONTEXTthe document's context, report and refresh channels
BLASDOC_CODE_BLOCK_COMPONENTthe component every fence renders as
BLASDOC_CONTEXTthe application-wide expression context
BLASDOC_PARSE_OPTIONSthe application-wide parser options

@blasdoc/highlight

ts
provideBlasdocHighlight({ themes, defaultTheme?, ensureContrast? });
ts
import { BlasdocHighlighter } from '@blasdoc/highlight';
 
highlighter.peek(request);       // what to show now, without waiting
highlighter.highlight(request);  // the highlighted IR
highlighter.themeNames();

@blasdoc/components

ts
import {
  BlasdocCodeBlockState,
  BlasdocCodeBlock, BlasdocTabList, BlasdocTab,
  BlasdocTabPanel, BlasdocCopy, BlasdocMode,
  codeNodesToTabs, readThemeOverride,
} from '@blasdoc/components';

@blasdoc/theme-default

ts
provideBlasdocTheme();
ts
import { BlasdocContentStyles } from '@blasdoc/theme-default';

@blasdoc/build

Angular builders, used from angular.json or project.json:

text
@blasdoc/build:application
@blasdoc/build:dev-server

And a TypeScript language-service plugin, used from tsconfig.json:

json
{ "compilerOptions": { "plugins": [{ "name": "@blasdoc/build" }] } }