XMarkdown plugins
Plug-ins are divided into two categories. Objects with transform(content) in plugins will rewrite the Markdown string before parsing. Formulas, highlighting, and Mermaid use the marked extension or components mapping, just like React @ant-design/x-markdown@2.10.0.
Publish the subpath in the package:
@ant-design-x-vue/x-markdown/plugins/Latex@ant-design-x-vue/x-markdown/plugins/HighlightCode@ant-design-x-vue/x-markdown/plugins/Mermaid
The main entrance also exports these three names. The browser script package does not have a separate copy of dist/plugins/*.min.js, please use the package entry or subpath.
String transform
Ship the TODO before Friday.
Latex
Latex(options?) returns marked extensions, which are passed to config.extensions. By default, align* is replaced with aligned. katexOptions are passed directly to KaTeX.
| Prop | Description | Type | Default |
|---|---|---|---|
| replaceAlignStart | Whether to replace align* with aligned | boolean | true |
| katexOptions | KaTeX configuration | KatexOptions | { output: 'html', throwOnError: false } |
Pythagoras: .
Standalone page: Formulas.
HighlightCode
Fenced code is rendered as <code class="language-*">. The class is read via components.code and then passed to HighlightCode. Inline code remains as standard <code>.
| Prop | Description | Type | Default |
|---|---|---|---|
| lang | Language name | string | - |
| children | Code text | string | - |
| header | Top bar; if null, the default top bar is not rendered | VNode | null | Default top bar |
| className | Root class name | string | - |
| classNames | root / header / headerTitle / code | object | - |
| styles | Inline styles corresponding to classNames | object | - |
A fenced block picks up the language class:
tsexport const answer = 42;
Inline const x = 1 stays a plain code tag.
Standalone page: Highlighted Code.
Mermaid
components.code is replaced by Mermaid when the language is mermaid. The chart library is only initialized in the browser, and server-side rendering displays the source code first.
| Prop | Description | Type | Default |
|---|---|---|---|
| children | Chart source code | string | - |
| header | Top bar; do not render the default toolbar when null | VNode | null | Default toolbar |
| className | Root class name | string | - |
| classNames | root / header / graph / code | object | - |
| styles | Inline styles corresponding to classNames | object | - |
```mermaid graph TD A[Start] --> B[Answer] ```
Here are several Mermaid diagram examples
#### 1. Flowchart (Vertical)
``` mermaid
graph TD
A[Start] --> B{Data Valid?}
B -->|Yes| C[Process Data]
B -->|No| D[Error Handling]
C --> E[Generate Report]
D --> E
E --> F[End]
style A fill:#2ecc71,stroke:#27ae60
style F fill:#e74c3c,stroke:#c0392b
```
#### 2. Sequence Diagram
``` mermaid
sequenceDiagram
participant Client
participant Server
participant Database
Client->>Server: POST /api/data
Server->>Database: INSERT record
Database-->>Server: Success
Server-->>Client: 201 Created
```
#### 3. Quadrant Chart
```mermaid
quadrantChart
title Reach and engagement of campaigns
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 We should expand
quadrant-2 Need to promote
quadrant-3 Re-evaluate
quadrant-4 May be improved
Campaign A: [0.3, 0.6]
Campaign B: [0.45, 0.23]
Campaign C: [0.57, 0.69]
Campaign D: [0.78, 0.34]
Campaign E: [0.40, 0.34]
Campaign F: [0.35, 0.78]
```
Independent page: Mermaid · GPT-VIS.
Think
Custom labels can be mapped to dialog components. think is handed over to Think, the default slot is the text in the label. Sources / ThoughtChain use the same components notation, see Chat Enhancement.
The answer is 42.
Theme and copy
The button text of HighlightCode and Mermaid comes from useLocale. Use XProvider to wrap it up and replace it. Styles are available in the components styles / classNames, or follow the ant-design-vue Design Token. See Theme and Copy for details. For the Markdown text theme class name, see theme.
Custom plugin
Supports marked extensions or custom plug-ins with transform, see custom plug-in.