@covalent/markdown

中文文档
11.23.0发布于 2026/10/02MITTypeScriptESM + CJS近 30 天下载 4654

Teradata UI Platform Markdown Module

原始使用文档
文档目录8 节
  1. TdMarkdownComponent: td-markdown
  2. API Summary
  3. Installation
  4. Setup
  5. Theming
  6. Example
  7. Sub Heading (H2)
  8. Steps (H2)

TdMarkdownComponent: td-markdown

<td-markdown> is a component that parses and renders Github flavored markdown. It is based on the showdown library.

Note: This module uses the DomSanitizer service to sanitize the parsed html from the showdown lib to avoid XSS issues.

By default, --dev build will log the following message in the console to let you know:

WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).

API Summary

Inputs

  • content?: string

    • Markdown format content to be parsed as html markup.
    • Used to load data dynamically. e.g. README.md content.
  • simpleLineBreaks?: string

    • Sets whether newline characters inside paragraphs and spans are parsed as
      .
    • Defaults to false.
  • hostedUrl?: string

    • If markdown contains relative paths, this is required to generate correct urls.
  • anchor?: string

    • Anchor to jump to.
  • fileLinkExtensions?: string[]

    • The file extensions to monitor within anchor tags.
    • Clicking links that end with these extensions will prevent the default action and emit 'fileClicked' event.

Events

  • contentReady: undefined

    • Event emitted after the markdown content rendering is finished.
  • fileLinkClicked: URL

    • Emitted when an anchor tag is clicked and its 'href' matches one of the extensions in 'fileLinkExtensions'.

Installation

This component can be installed as an npm package.

npm i -save @covalent/markdown

Setup

Then, import the CovalentMarkdownModule in your NgModule:

import { CovalentMarkdownModule } from '@covalent/markdown';
@NgModule({
  imports: [
    CovalentMarkdownModule,
    ...
  ],
  ...
})
export class MyModule {}

Theming

This module comes with its own Covalent theme which uses the material theme which is used by importing our theme scss file.

@use '@angular/material/theming' as mat;
@use '@covalent/markdown/markdown-theme' as markdown;

@include mat.core();

$primary: mat.define-palette($mat-orange, 800);
$accent: mat.define-palette($mat-light-blue, 600, A100, A400);
$warn: mat.define-palette($mat-red, 600);

$theme: mat.define-light-theme($primary, $accent, $warn);

@include markdown.covalent-markdown-theme($theme);

Example

Html:

<td-markdown> # Heading ## Sub Heading (H2) ### Steps (H2) </td-markdown>

Output:

Heading

Sub Heading (H2)

Steps (H2)

版本与发布记录

@covalent/markdown 共发布 440 个版本,首次发布于 2016/07/13;过去 12 个月发布了 74 个版本。

版本发布日期距今
11.23.0latest2026/10/021 个月前
11.22.12026/09/102 个月前
11.22.02026/09/102 个月前
11.21.02026/09/092 个月前
10.5.82026/07/293 个月前
11.20.12026/07/293 个月前

其他发布通道:next → 11.5.2-beta.1。

关于 @covalent/markdown 的常见问题

@covalent/markdown 是什么?

Teradata UI Platform Markdown Module

如何安装 @covalent/markdown?

在项目目录运行 npm install @covalent/markdown,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:showdown(^2.1.0)、@angular/core(20.x.x)、@angular/common(20.x.x)、@angular/platform-browser(20.x.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@covalent/markdown 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@covalent/markdown 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@covalent/markdown 可以商用吗?

@covalent/markdown 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@covalent/markdown 的下载量有多少?

根据 npm 官方下载统计,@covalent/markdown 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,654 次,日均约 155 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@covalent/markdown 还在维护吗?

最新版本 11.23.0 发布于 2026/10/02(1 个月前);至今共发布 440 个版本,其中过去 12 个月发布了 74 个;首次发布于 2016/07/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。