Closed Deanozk closed 6 months ago
There is a three line example in the README which is as complete example as you can get.
// For Node.js
var TurndownService = require('turndown')
var turndownService = new TurndownService()
var markdown = turndownService.turndown('<h1>Hello world!</h1>')
The first line (as indicated by the comment) is only for NodeJS environment (specifically for CommonJS modules). The only thing that might be added is that in ESM environment you should use import
statement instead of require
(possibly your use-case?). But that seems like trivial thing to deduce.
You might want to try this:
import TurndownService from 'turndown'
var turndownService = new TurndownService()
var markdown = turndownService.turndown('<h1>Hello world!</h1>')
That being said, this is not a better example than the one in the README.
var TurndownService = require('turndown') ^ ReferenceError: require is not defined in ES module scope, you can use import instead
This is not the best way to startout using a library.