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 express = require('express');
|
||||||
const req = require('express/lib/request');
|
|
||||||
|
|
||||||
module.exports = function (options) {
|
module.exports = function (options) {
|
||||||
const db = options.db;
|
const db = options.db;
|
||||||
@@ -174,13 +175,9 @@ module.exports = function (options) {
|
|||||||
}).then(artifactVersion => {
|
}).then(artifactVersion => {
|
||||||
const isString = typeof request.body.text === "string" || request.body.text instanceof String
|
const isString = typeof request.body.text === "string" || request.body.text instanceof String
|
||||||
if (artifactVersion && isString) {
|
if (artifactVersion && isString) {
|
||||||
const chunks = request.body.text.trim().split(/\r?\n/).filter(text => {
|
const chunks = md.parse(
|
||||||
if (text) {
|
request.body.text
|
||||||
return true
|
).filter(token => token.content).map(token => token.content/*.replace(/\n/g,' ')*/)
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
db.Chapter.create({
|
db.Chapter.create({
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
name: chunks[0].trim(),
|
name: chunks[0].trim(),
|
||||||
|
|||||||
Reference in New Issue
Block a user