Parse the markdown to tokenize it
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const md = require("markdown-it")().disable(['link'])
|
||||
const express = require('express');
|
||||
const req = require('express/lib/request');
|
||||
|
||||
|
||||
module.exports = function (options) {
|
||||
const db = options.db;
|
||||
@@ -174,13 +175,9 @@ module.exports = function (options) {
|
||||
}).then(artifactVersion => {
|
||||
const isString = typeof request.body.text === "string" || request.body.text instanceof String
|
||||
if (artifactVersion && isString) {
|
||||
const chunks = request.body.text.trim().split(/\r?\n/).filter(text => {
|
||||
if (text) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
const chunks = md.parse(
|
||||
request.body.text
|
||||
).filter(token => token.content).map(token => token.content/*.replace(/\n/g,' ')*/)
|
||||
db.Chapter.create({
|
||||
creatorId: request.user.id,
|
||||
name: chunks[0].trim(),
|
||||
|
||||
Reference in New Issue
Block a user