From e2637ced5ad6403f071924012c549ca4920e1ce2 Mon Sep 17 00:00:00 2001
From: Ion Riciu <Ion.Riciu@endava.com>
Date: Wed, 14 Apr 2021 11:06:24 +0300
Subject: [PATCH] fix: article formatting in Hyphotesis

---
 package.json                           |  1 +
 server/model-manuscript/src/graphql.js |  4 +++-
 yarn.lock                              | 12 ++++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/package.json b/package.json
index 51023f5980..c41e204c0c 100644
--- a/package.json
+++ b/package.json
@@ -164,6 +164,7 @@
     "styled-components": "^5.2.1",
     "superagent": "^3.8.3",
     "supertest": "3.4.2",
+    "turndown": "^7.0.0",
     "waait": "^1.0.5",
     "wax-prosemirror-core": "0.0.40",
     "wax-prosemirror-plugins": "0.0.40",
diff --git a/server/model-manuscript/src/graphql.js b/server/model-manuscript/src/graphql.js
index a9a028c8a1..31b091fe5d 100644
--- a/server/model-manuscript/src/graphql.js
+++ b/server/model-manuscript/src/graphql.js
@@ -1,4 +1,5 @@
 const { ref, raw } = require('objection')
+const TurndownService = require('turndown')
 const axios = require('axios')
 const { GoogleSpreadsheet } = require('google-spreadsheet')
 const credentials = require('../../../google_sheets_credentials.json')
@@ -273,9 +274,10 @@ const resolvers = {
       let manuscript = await ctx.models.Manuscript.query().findById(id)
 
       if (['elife'].includes(process.env.INSTANCE_NAME)) {
+        const turndownService = new TurndownService({bulletListMarker: '-'})
         const requestBody = {
           uri: manuscript.submission.articleURL,
-          text: manuscript.submission.evaluationContent,
+          text: turndownService.turndown(manuscript.submission.evaluationContent),
           tags: [manuscript.submission.evalType],
           // group: "q5X6RWJ6",
         }
diff --git a/yarn.lock b/yarn.lock
index 7352381b11..1db4321bd5 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8030,6 +8030,11 @@ domhandler@^4.0.0:
   dependencies:
     domelementtype "^2.1.0"
 
+domino@^2.1.6:
+  version "2.1.6"
+  resolved "https://registry.yarnpkg.com/domino/-/domino-2.1.6.tgz#fe4ace4310526e5e7b9d12c7de01b7f485a57ffe"
+  integrity sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==
+
 domutils@^1.5.1, domutils@^1.7.0:
   version "1.7.0"
   resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"
@@ -19787,6 +19792,13 @@ tunnel-agent@^0.6.0:
   dependencies:
     safe-buffer "^5.0.1"
 
+turndown@^7.0.0:
+  version "7.0.0"
+  resolved "https://registry.yarnpkg.com/turndown/-/turndown-7.0.0.tgz#19b2a6a2d1d700387a1e07665414e4af4fec5225"
+  integrity sha512-G1FfxfR0mUNMeGjszLYl3kxtopC4O9DRRiMlMDDVHvU1jaBkGFg4qxIyjIk2aiKLHyDyZvZyu4qBO2guuYBy3Q==
+  dependencies:
+    domino "^2.1.6"
+
 tweetnacl@^0.14.3, tweetnacl@~0.14.0:
   version "0.14.5"
   resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
-- 
GitLab