File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 35
35
"sequelize" : " ^4.21.0" ,
36
36
"superagent" : " ^3.8.0" ,
37
37
"tc-core-library-js" : " appirio-tech/tc-core-library-js.git#v2.2" ,
38
- "winston" : " ^2.2.0"
38
+ "winston" : " ^2.2.0" ,
39
+ "remarkable" : " ^1.7.1"
39
40
},
40
41
"engines" : {
41
42
"node" : " 6.x"
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ function startKafkaConsumer(handlers) {
113
113
name : user . firstName + ' ' + user . lastName ,
114
114
handle : user . handle ,
115
115
topicTitle : connectTopic . title || '' ,
116
- post : messageJSON . postContent ,
116
+ post : helperService . markdownToHTML ( messageJSON . postContent ) ,
117
117
date : ( new Date ( ) ) . toISOString ( ) ,
118
118
projectName : notification . contents . projectName ,
119
119
projectId : messageJSON . projectId ,
Original file line number Diff line number Diff line change 4
4
const request = require ( 'superagent' ) ;
5
5
const config = require ( 'config' ) ;
6
6
const _ = require ( 'lodash' ) ;
7
-
7
+ const Remarkable = require ( 'remarkable' )
8
8
9
9
/**
10
10
* Get users details by ids
@@ -63,7 +63,29 @@ const getTopic = (topicId, logger) => request
63
63
} ) ;
64
64
65
65
66
+
67
+ /**
68
+ * Convert markdown into raw draftjs state
69
+ *
70
+ * @param {String } markdown - markdown to convert into raw draftjs object
71
+ * @param {Object } options - optional additional data
72
+ *
73
+ * @return {Object } ContentState
74
+ **/
75
+ const markdownToHTML = ( markdown ) => {
76
+ const md = new Remarkable ( 'full' , {
77
+ html : true ,
78
+ linkify : true ,
79
+ // typographer: true,
80
+ } )
81
+ // Replace the BBCode [u][/u] to markdown '++' for underline style
82
+ const _markdown = markdown . replace ( new RegExp ( '\\[/?u\\]' , 'g' ) , '++' )
83
+ return md . render ( _markdown , { } ) // remarkable js takes markdown and makes it an array of style objects for us to easily parse
84
+ }
85
+
86
+
66
87
module . exports = {
67
88
getUsersById,
68
89
getTopic,
90
+ markdownToHTML,
69
91
} ;
You can’t perform that action at this time.
0 commit comments