OneScript

Markdown

Render Markdown text.

Markdown parses and renders Markdown natively, supporting CommonMark and GitHub Flavored Markdown. It is a good fit for help text, release notes, and chat replies. Text can be selected, and tapping a link opens it in the system.

import { Markdown } from "onescript/views"

const source = `# Release notes

Supports **bold**, *italic*, \`inline code\` and [links](https://onescript.define.to).

- [x] Tables and task lists
- [ ] Ship it`

<Markdown>{source}</Markdown>
PropTypeDescription
childrenstringMarkdown source text.

Also supports Modifiers. It is only available in App and Action view sessions; widgets reject it with an unsupported view type error.

Supported syntax

  • Headings, paragraphs, bold, italic, strikethrough, inline code, and links
  • Ordered, unordered, and task lists
  • Block quotes and horizontal rules
  • Fenced code blocks with syntax highlighting
  • Tables
  • Inline and block math: $...$ and $$...$$

Images are shown as links. HTML is shown as plain text and is not rendered.

Behavior

  • The view fills the available width and grows vertically to fit its content. Place long documents in a ScrollView.
  • Fonts and colors follow the system. Text modifiers such as font and foregroundStyle do not apply to the content; layout modifiers such as padding, frame, and background do.
  • Updating children re-renders the content, so you can stream text into it, for example while showing a chat reply.

How is this guide?

Last updated on

On this page