Wiki source code of Markdown Front-End Rendering
Last modified by Manuel Leduc on 2026/03/23 11:23
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Provides the parsers and serializers from Markdown. | ||
| 2 | |||
| 3 | Package name: ##@xwiki/platform-uniast-markdown## | ||
| 4 | |||
| 5 | == Exposed components == | ||
| 6 | |||
| 7 | * ##MarkdownToUniAstConverter## with identifier ##markdownToUniAstConverterName## | ||
| 8 | * ##UniAstToMarkdownConverter## with identifier ##uniAstToMarkdownConverterName## | ||
| 9 | |||
| 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 | |||
| 22 | {{code language="typescript"}} | ||
| 23 | import { Container } from 'inversify'; | ||
| 24 | import { InlineContent } from '@xwiki/platform-uniast-api'; | ||
| 25 | import { Link } from '@xwiki/platform-uniast-api'; | ||
| 26 | import { LinkTarget } from '@xwiki/platform-uniast-api'; | ||
| 27 | import { UniAst } from '@xwiki/platform-uniast-api'; | ||
| 28 | |||
| 29 | // @beta (undocumented) | ||
| 30 | export class ComponentInit { | ||
| 31 | constructor(container: Container); | ||
| 32 | } | ||
| 33 | |||
| 34 | // @beta | ||
| 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 | ||
| 45 | export interface MarkdownToUniAstConverter { | ||
| 46 | parseMarkdown(markdown: string): Promise<UniAst | Error>; | ||
| 47 | } | ||
| 48 | |||
| 49 | // @beta (undocumented) | ||
| 50 | export const markdownToUniAstConverterName = "MarkdownToUniAstConverter"; | ||
| 51 | |||
| 52 | // @beta | ||
| 53 | export interface UniAstToMarkdownConverter { | ||
| 54 | convertInlineContents(inlineContents: InlineContent[]): Promise<string | Error>; | ||
| 55 | toMarkdown(uniAst: UniAst): Promise<string | Error>; | ||
| 56 | toMarkdown(uniAst: UniAst): Promise<string | Error>; | ||
| 57 | } | ||
| 58 | |||
| 59 | // @beta (undocumented) | ||
| 60 | export const uniAstToMarkdownConverterName = "UniAstToMarkdownConverter"; | ||
| 61 | {{/code}} |