Skip to main content

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

options
object
Configuration object to customize the conversion behavior

Returns

turndownService
TurndownService
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

Build docs developers (and LLMs) love