Markdown

Use Markdown to add content to your forms.

Use the Markdown functions to create formatted text content in your forms. These functions help you create common elements like paragraphs, headings, lists, and more.

<div> elements are also supported. See block-level data binding.

Basic usage

import { Composer } from "formsmd";

const composer = new Composer({
  id: "my-form"
});

composer.h1("Heading");
composer.p("This is a **paragraph**.");
composer.hr();
composer.ul([
  "Item 1",
  "Item 2",
  "Item 3"
]);
composer.blockquote("Quote");
composer.code("var a = 5;", {
  language: "javascript"
});

Generates the following Markdown:


Parameters

These parameters are common to all Markdown functions (except for the horizontal rule):

Name
Type
Description

id

string

The id attribute of the element.

classNames

string[]

The CSS class names of the element. See the available CSS utility classes.

attrs

Array<{ name: string, value: string }>

Other HTML attributes of the element. Each attribute has a name and value property.

Code parameter

Additional parameter for the code element:

Name
Type
Description

language

string

The language of the code.


Headings

Create heading elements from level 1 (largest) to level 6 (smallest).

Function overview

Example

Generates the following Markdown:


Paragraph

Create paragraph elements for body text.

Function overview

Example

Generates the following Markdown:


Lists (unordered, ordered, task)

Create unordered (bulleted) and ordered (numbered) lists.

Function overview

Unordered list example

Generates the following Markdown:

Ordered list example

Generates the following Markdown:

Task list example

Add the .list-unstyled class and use [ ] or [x] in the items to create task lists:

Generates the following Markdown:


Blockquote

Create blockquote elements for quoted or highlighted content.

Function overview

Example

Generates the following Markdown:


Code

Create code blocks with optional language specification.

Function overview

Example

Generates the following Markdown:


Horizontal rule

Create horizontal line dividers.

Function overview

Example

Generates the following Markdown:

If the slide delimiter is set to "***", horizontal rules will automatically use "---" instead to avoid confusion with slide breaks.


Free-form content

Add arbitrary content that will be included exactly as written.

Function overview

Example

Generates the following Markdown:

Last updated

Was this helpful?