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. .
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:
#! id = my-form
# Heading
This is a **paragraph**.
***
- Item 1
- Item 2
- Item 3
> Quote
```javascript
var a = 5;
```
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[]
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).