Wiki source code of Markdown Front-End Rendering
Last modified by Manuel Leduc on 2026/03/23 11:23
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
3.2 | 1 | Provides the parsers and serializers from Markdown. |
| |
3.1 | 2 | |
| |
8.1 | 3 | Package name: ##@xwiki/platform-uniast-markdown## |
| |
2.1 | 4 | |
| 5 | == Exposed components == | ||
| 6 | |||
| |
3.4 | 7 | * ##MarkdownToUniAstConverter## with identifier ##markdownToUniAstConverterName## |
| 8 | * ##UniAstToMarkdownConverter## with identifier ##uniAstToMarkdownConverterName## | ||
| |
2.1 | 9 | |
| |
12.1 | 10 | == Exported interfaces == |
| 11 | |||
| 12 | {{version since='18.2.0RC1'}} | ||
| 13 | === InternalLinksSerializer === | ||
| 14 | A component that is expected to be implemented by backends, defining how links and images are serialized | ||
| 15 | |||
| 16 | Existing implementations: | ||
| 17 | * ##@xwiki/platform-uniast-markdown-xwiki## | ||
| 18 | {{/version}} | ||
| 19 | |||
| 20 | == API Extractor | ||
| 21 | |||
| |
2.1 | 22 | {{code language="typescript"}} |
| 23 | import { Container } from 'inversify'; | ||
| |
6.1 | 24 | import { InlineContent } from '@xwiki/platform-uniast-api'; |
| |
12.1 | 25 | import { Link } from '@xwiki/platform-uniast-api'; |
| 26 | import { LinkTarget } from '@xwiki/platform-uniast-api'; | ||
| |
6.1 | 27 | import { UniAst } from '@xwiki/platform-uniast-api'; |
| |
2.1 | 28 | |
| |
12.1 | 29 | // @beta (undocumented) |
| |
2.1 | 30 | export class ComponentInit { |
| 31 | constructor(container: Container); | ||
| 32 | } | ||
| 33 | |||
| 34 | // @beta | ||
| |
12.1 | 35 | export interface InternalLinksSerializer { |
| 36 | serialize(content: Link["content"], target: Extract<LinkTarget, { | ||
| 37 | type: "internal"; | ||
| 38 | }>, uniAstToMarkdownConverter: UniAstToMarkdownConverter): Promise<string>; | ||
| 39 | serializeImage(target: Extract<LinkTarget, { | ||
| 40 | type: "internal"; | ||
| 41 | }>, alt?: string): Promise<string>; | ||
| 42 | } | ||
| 43 | |||
| 44 | // @beta | ||
| |
2.1 | 45 | export interface MarkdownToUniAstConverter { |
| 46 | parseMarkdown(markdown: string): Promise<UniAst | Error>; | ||
| 47 | } | ||
| 48 | |||
| |
12.1 | 49 | // @beta (undocumented) |
| |
2.1 | 50 | export const markdownToUniAstConverterName = "MarkdownToUniAstConverter"; |
| 51 | |||
| 52 | // @beta | ||
| 53 | export interface UniAstToMarkdownConverter { | ||
| |
4.1 | 54 | convertInlineContents(inlineContents: InlineContent[]): Promise<string | Error>; |
| |
2.1 | 55 | toMarkdown(uniAst: UniAst): Promise<string | Error>; |
| |
8.1 | 56 | toMarkdown(uniAst: UniAst): Promise<string | Error>; |
| |
2.1 | 57 | } |
| 58 | |||
| |
12.1 | 59 | // @beta (undocumented) |
| |
2.1 | 60 | export const uniAstToMarkdownConverterName = "UniAstToMarkdownConverter"; |
| 61 | {{/code}} |