Syntax
var turndownService = new TurndownService([options])
// or
var turndownService = TurndownService([options])
Description
Creates a new instance of TurndownService with optional configuration. The constructor can be called with or without the new keyword.
Parameters
Configuration object to customize the conversion behavior
Style for headings: setext or atx
Markdown representation for horizontal rules
Character for bullet list items: *, -, or +
Style for code blocks: indented or fenced
Fence characters for code blocks: ``` or ~~~
Delimiter for emphasis: _ or *
Delimiter for strong emphasis: ** or __
Style for links: inlined or referenced
Style for link references: full, collapsed, or shortcut
Markdown representation for line breaks
Whether to preserve whitespace in code blocks
Custom replacement function for blank elements
Custom replacement function for kept elements
Custom replacement function for unrecognized elements
Returns
A new TurndownService instance configured with the provided options
Examples
Basic Usage
var TurndownService = require('turndown')
var turndownService = new TurndownService()
With Options
var turndownService = new TurndownService({
headingStyle: 'atx',
codeBlockStyle: 'fenced',
bulletListMarker: '-'
})
Without new Keyword
var turndownService = TurndownService({ emDelimiter: '*' })
Notes
- The constructor automatically returns a new instance even if called without the
new keyword
- All options have sensible defaults based on CommonMark specification
- Options can be accessed later via
turndownService.options