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.
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):
id
string
The id attribute of the element.
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:
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:
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?