import express from 'express'
import Feed from 'pfeed'
+import { mdToPlainText, toSafeHtml } from '@server/helpers/markdown'
import { getServerActor } from '@server/models/application/application'
import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
import { VideoInclude } from '@shared/models'
title,
id: comment.url,
link,
- content: comment.text,
+ content: toSafeHtml(comment.text),
author,
date: comment.createdAt
})
return new Feed({
title: name,
- description,
+ description: mdToPlainText(description),
// updated: TODO: somehowGetLatestUpdate, // optional, default = today
id: webserverUrl,
link: webserverUrl,
title: video.name,
id: video.url,
link: WEBSERVER.URL + video.getWatchStaticPath(),
- description: video.getTruncatedDescription(),
- content: video.description,
+ description: mdToPlainText(video.getTruncatedDescription()),
+ content: toSafeHtml(video.description),
author: [
{
name: video.VideoChannel.Account.getDisplayName(),
markdownIt.enable(TEXT_WITH_HTML_RULES)
markdownIt.use(markdownItEmoji)
-const toSafeHtml = text => {
+const toSafeHtml = (text: string) => {
if (!text) return ''
// Restore line feed
return sanitizeHtml(html, sanitizeOptions)
}
-const mdToPlainText = text => {
+const mdToPlainText = (text: string) => {
if (!text) return ''
// Convert possible markdown (emojis, emphasis and lists) to html
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
- expect(jsonObj.items[0].html_content).to.equal('super comment 2')
- expect(jsonObj.items[1].html_content).to.equal('super comment 1')
+ expect(jsonObj.items[0].html_content).to.contain('<p>super comment 2</p>')
+ expect(jsonObj.items[1].html_content).to.contain('<p>super comment 1</p>')
}
})