support markdown in descriptions

also convert html descriptions from Audible and iTunes to markdown
This commit is contained in:
MxMarx 2023-09-29 17:48:44 -07:00
parent ed82a5aa19
commit 41b685d118
6 changed files with 42 additions and 8 deletions

View file

@ -1,5 +1,6 @@
const { xmlToJSON } = require('../index')
const htmlSanitizer = require('../htmlSanitizer')
const TurndownService = require('turndown')
var turndownService = new TurndownService()
function parseCreators(metadata) {
if (!metadata['dc:creator']) return null
@ -87,7 +88,7 @@ function fetchDescription(metadata) {
// check if description is HTML or plain text. only plain text allowed
// calibre stores < and > as &lt; and &gt;
description = description.replace(/&lt;/g, '<').replace(/&gt;/g, '>')
return htmlSanitizer.stripAllTags(description)
return turndownService.turndown(description)
}
function fetchGenres(metadata) {