Options
All
  • Public
  • Public/Protected
  • All
Menu

jsx-md

internal

Index

Type aliases

Component

Component<ComponentProps>: (props: ComponentProps) => MarkdownElement | null

Type parameters

  • ComponentProps: unknown = unknown

Type declaration

    • A functional component that creates Markdown elements.

      Parameters

      • props: ComponentProps

      Returns MarkdownElement | null

MarkdownChildren

MarkdownChildren: MarkdownNode | MarkdownChildren[]

Nested Markdown type.

MarkdownElement

MarkdownElement<Props>: MdFunctionElement<Props> | MdFragmentElement | MdAwaitElement

Internal representation of markdown before rendering.

Type parameters

  • Props = unknown

MarkdownNil

MarkdownNil: false | null | undefined

Nil types that get ignored.

Functions

Const BlockQuote

  • BlockQuote(props: Props): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • Wraps a string in a blockquote, automatically taking care of line breaks.

    example
    render(<BlockQuote>Test1{'/n'}Test2</BlockQuote>)
    ===
    `
    > Test1
    > Test2
    `

    Parameters

    • props: Props

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const CodeBlock

  • CodeBlock(props: Props): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • Wraps a string in a code block.

    example
    render(<CodeBlock language="ts">console.log("Test")</CodeBlock>)
    ===
    '```ts\n'
    + 'console.log("Test")\n
    + '```\n'

    Parameters

    • props: Props

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const Heading

  • Heading(props: PropsWithChildren<Props>): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • Marks text as a heading.

    example
    render(<Heading level={1}>Test</Heading>)
    ===
    '# Test\n\n'

    Parameters

    • props: PropsWithChildren<Props>

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const Image

  • Image(props: Props): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • example
    render(<Image src="./image.png" title="Title">
    Alternative text
    </Image>)
    ===
    '![Alternative text](./image.png "Title")'

    Parameters

    • props: Props

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const Italics

  • Italics(props: { children?: MarkdownChildren }): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const Link

  • Link(props: PropsWithChildren<Props>): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • example
    render(<Link to="https://example.com" title="Title">
    Test
    </Link>)
    ===
    '[Test](https://example.com "Title")'

    Parameters

    • props: PropsWithChildren<Props>

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const ReferenceImage

  • ReferenceImage(props: PropsWithChildren<Props>): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • example
    render(<ReferenceImage reference="logo">
    Alternative text
    </ReferenceImage>)
    ===
    '![Alternative text][logo]'

    Parameters

    • props: PropsWithChildren<Props>

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const Strikethrough

  • Strikethrough(props: { children?: MarkdownChildren }): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Table

  • Table<Headers>(__namedParameters: Props<Headers>): ReturnType<Component<Props<Headers>>>
  • Creates a markdown table based on a headers object and an array of rows. Columns are ordered in the order in which the header keys were created.

    paramtype

    A union of possible keys for headers and body

    example
    const headers = {
    foo: "Foo header",
    bar: { title: "Bar header", alignment: TableAlignment.CENTER },
    baz: { title: "Baz header" },
    };
    const body = [
    { foo: "Foo body 1", bar: "Bar body 1", baz: "Baz body 1" },
    { foo: "Foo body 2", bar: "Bar body 2", baz: "Baz body 2" },
    ];
    render(<Table headers={headers} body={body} />)
    ===
    `
    | Foo header | Bar header | Baz header |
    | ---------- | :--------: | ---------- |
    | Foo body 1 | Bar body 1 | Baz body 1 |
    | Foo body 2 | Bar body 2 | Baz body 2 |
    `

    Type parameters

    • Headers: string

    Parameters

    • __namedParameters: Props<Headers>

    Returns ReturnType<Component<Props<Headers>>>

Const Task

  • Task(props: PropsWithChildren<Props>): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • example
    render(<Task checked>Test</Task>)
    ===
    '- [x] Test'

    Parameters

    • props: PropsWithChildren<Props>

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

Const UnorderedList

  • UnorderedList(props: Props): null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>
  • example
    render(<UnorderedList>
    {"a"}
    {"b"}
    {"c"}
    </UnorderedList>)
    ===
    `* a
    * b
    * c
    `

    Parameters

    • props: Props

    Returns null | MdFragmentElement | MdAwaitElement | MdFunctionElement<unknown>

awaitComponent

  • awaitComponent<Props>(componentFn: (props: Props) => Promise<null | MdFragmentElement | MdAwaitElement | MdFunctionElement<Props>>): Component<Props>
  • Wraps a function that returns a promise to be a valid component

    example
    const AsyncText = awaitComponent(async ({ children }) => (
    <Text>{children}</Text>
    ));
    render(<AsyncText>Test</AsyncText>))
    ===
    `Hello`

    Type parameters

    • Props

    Parameters

    • componentFn: (props: Props) => Promise<null | MdFragmentElement | MdAwaitElement | MdFunctionElement<Props>>
        • (props: Props): Promise<null | MdFragmentElement | MdAwaitElement | MdFunctionElement<Props>>
        • Parameters

          • props: Props

          Returns Promise<null | MdFragmentElement | MdAwaitElement | MdFunctionElement<Props>>

    Returns Component<Props>

Generated using TypeDoc