A markup language for generating random text.
LoreML is a markup language for generating random text.
``bash`
npm i loreml
`javascript
import LoreML from 'loreml'
const loreml = new LoreML()
const text = await loreml.parse(
)`
The root element of the document.
- Attributes
- seed - A seed value for the random number generator. If not provided, a random seed will be generated.locale
- - The locale of the generated text. Possible values are:en
- - English (default)es
- - Spanishfr
- - Frenchde
- - Germanit
- - ItalianDocument
- Children
- Template
- Person
- Location
-
A template is a named block of text that can be reused in the document.
- Attributes
- name - (required) The name of the template.Text
- Children
-
- Example
`xml`
Greetings {nameVar}
Generates a random person.
- Attributes
- ref - (required) A reference to the person for later use.sex
- - The sex of the person. If not specified, a random one will be picked. Possible values are male and female.
- Example
`xml`
Generates a random location.
- Attributes
- ref - (required) A reference to the location for later use.
- Example
`xml`
Denotes the output of a text document.
- Children
- Text
A Text element can contain any number of self-closing elements, other Text tags, and also inline raw text.
- Attributes
- repeat - The number of times to repeat the text. If not provided, the text will be repeated once.pick
- - Sample _N_ children at random. If not provided, all children will be included.
- Children
- TextUseTemplate
- UsePerson
- Sentence
- Paragraph
- Date
- UniformInt
- UniformFloat
-
Inserts a pre-defined template into the document.
- Attributes
- ref - (required) The name of the template to use.[varName: string]: string
- - Variables to replace in the template.
- Example
`xml`
Greetings {nameVar}
nameVar="Lorem"
/>
Inserts a pre-defined location into the document. Uses child elements to specify which properties of the location to include.
- Attributes
- ref - (required) The reference of the location to use.
- Children
- AddressStreet
- City
- State
- Zip
- Country
-
- Example
`xml`
Inserts a pre-defined person into the document. Uses child elements to specify which properties of the person to include.
- Attributes
- ref - (required) The reference of the person to use.
- Children
- SexPrefix
- FirstName
- LastName
- MiddleName
- FullName
-
- Phone
- Address
- Street
- City
- State
- Zip
- Country
-
- Example
`xml`
Generates a sentence of lorem ipsum text.
- Attributes
- min - The minimum number of words in the sentence. (Default: 3).max
- - The maximum number of words in the sentence. (Default: 10).
- Example
`xml`
Generates a paragraph of lorem ipsum text.
- Attributes
- min - The minimum number of sentences in the paragraph. (Default: 3).max
- - The maximum number of sentences in the paragraph. (Default: 10).
- Example
`xml`
Generates a random date.
- Attributes
- when - The time frame of the date. Possible values are recent, past, soon, future, anytime. (Default: anytime).format
- - The format of the date. See date-format (npm) for possible values.
- Example
`xml`
Generates a uniformly sampled random integer.
- Attributes
- min - The minimum value of the integer. (Default: 0).max
- - The maximum value of the integer. (Default: 10).
- Example
`xml`
Generates a uniformly sampled random float.
- Attributes
- min - The minimum value of the float. (Default: 0).max
- - The maximum value of the float. (Default: 10).
- Example
`xml``