ts-markdown has the following types of options:
MarkdownEntry
If there is additional options information you'd like to see here which wouldn't fit in FAQs, the cookbook, or the type docs, open a new GitHub issue requesting the type of options documentation you'd like to see.
Document-level options affect either a single entry type, a particular lifecycle event in document rendering, or some overarching aspect. Entry-specific options at the document-level are a convenient shortcut for applying your desired style to document rendering, reducing unnecessary props on your individual objects.
You can specify options at the document-level by passing in a RenderOptions
object when calling the tsMarkdown()
function:
const options: RenderOptions = {
useH1Underlining: true,
};
tsMarkdown(myEntries, options);
// 👆 H1 markdown will now have underlining whenever these options are passed into `tsMarkdown()`
Note: We Have Defaults
Any options that you do not specify fall back to a default value, so you do not have to specify all options. You can pick and choose the ones you want to specify.
Some markdown entries have their own entry-level options.
For example, unordered lists have an option for which indicator to use:
const ulEntry: UnorderedListEntry = {
ul: ['Hello, world!', 'Goodbye, Moon Man!'],
indicator: '+',
};
tsMarkdown([ulEntry]);
The result is a list with items indicated by +
:
+ Hello, world!
+ Goodbye, Moon Man!
Entry-level settings, if specified, take precedence over all else.
Then, document-level settings are considered.
Otherwise, we use defaults.
When specifying options, you may need to provide entry- and document-level options which conflict with each other.
For example, I want all bolded text to use underscores _
, except I want one entry to use asterisks *
:
import { tsMarkdown } from './rendering';
import { RenderOptions } from './rendering.types';
import { MarkdownEntry } from './shared.types';
const entry: MarkdownEntry = {
text: [
{ bold: 'Note' },
' - This ',
{ bold: 'is' },
' a ',
{
bold: 'sample',
// 👇 this is an entry-level option
indicator: '*',
},
],
};
// 👇 these are document-level options
const options: RenderOptions = {
boldIndicator: '_',
};
tsMarkdown([entry], options);
The rendered markdown is:
__Note__ - This __is__ a **sample**
For a full list of document-level and entry-level options, see the type documents for
RenderOptions
and the individual entry types, such asBoldEntry
.
Generated using TypeDoc