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 3535 "sequelize" : " ^4.21.0" ,
3636 "superagent" : " ^3.8.0" ,
3737 "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"
3940 },
4041 "engines" : {
4142 "node" : " 6.x"
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ function startKafkaConsumer(handlers) {
113113 name : user . firstName + ' ' + user . lastName ,
114114 handle : user . handle ,
115115 topicTitle : connectTopic . title || '' ,
116- post : messageJSON . postContent ,
116+ post : helperService . markdownToHTML ( messageJSON . postContent ) ,
117117 date : ( new Date ( ) ) . toISOString ( ) ,
118118 projectName : notification . contents . projectName ,
119119 projectId : messageJSON . projectId ,
Original file line number Diff line number Diff line change 44const request = require ( 'superagent' ) ;
55const config = require ( 'config' ) ;
66const _ = require ( 'lodash' ) ;
7-
7+ const Remarkable = require ( 'remarkable' )
88
99/**
1010 * Get users details by ids
@@ -63,7 +63,29 @@ const getTopic = (topicId, logger) => request
6363 } ) ;
6464
6565
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+
6687module . exports = {
6788 getUsersById,
6889 getTopic,
90+ markdownToHTML,
6991} ;
You can’t perform that action at this time.
0 commit comments