From 98d86bce53ef3359119d95f14b9e032b2632cb5f Mon Sep 17 00:00:00 2001 From: Tom <46689196+a-toms@users.noreply.github.com> Date: Sat, 11 Sep 2021 19:20:29 +0200 Subject: [PATCH] Add specific instructions for Vue - Added .default to allow Vue users to import turndown successfully. From https://stackoverflow.com/questions/55621010/using-turndown-in-vue-typeerror-turndownservice-is-not-a-constructor --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 500f0c5c..97cce6fd 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,22 @@ var turndownService = new TurndownService() var markdown = turndownService.turndown('

Hello world!

') ``` + + Turndown also accepts DOM nodes as input (either element nodes, document nodes, or document fragment nodes): ```js var markdown = turndownService.turndown(document.getElementById('content')) ``` +If using Vue, you may see an error: `TypeError: TurndownService is not a constructor` when trying to import Turndown. To fix this, add `.default` to the import. In other words: +```js +// example.vue +const TurndownService = require('turndown').default +``` + + + ## Options Options can be passed in to the constructor on instantiation. For example: