mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Workaround cheerio text method shouldn't preserve html tags on fetching note title
This commit is contained in:
parent
7e7919ce86
commit
11a8c0f9cf
1 changed files with 2 additions and 1 deletions
|
@ -13,6 +13,7 @@ var async = require('async');
|
||||||
var moment = require('moment');
|
var moment = require('moment');
|
||||||
var DiffMatchPatch = require('diff-match-patch');
|
var DiffMatchPatch = require('diff-match-patch');
|
||||||
var dmp = new DiffMatchPatch();
|
var dmp = new DiffMatchPatch();
|
||||||
|
var S = require('string');
|
||||||
|
|
||||||
// core
|
// core
|
||||||
var config = require("../config.js");
|
var config = require("../config.js");
|
||||||
|
@ -234,7 +235,7 @@ module.exports = function (sequelize, DataTypes) {
|
||||||
var $ = cheerio.load(md.render(body));
|
var $ = cheerio.load(md.render(body));
|
||||||
var h1s = $("h1");
|
var h1s = $("h1");
|
||||||
if (h1s.length > 0 && h1s.first().text().split('\n').length == 1)
|
if (h1s.length > 0 && h1s.first().text().split('\n').length == 1)
|
||||||
title = h1s.first().text();
|
title = S(h1s.first().text()).stripTags().s;
|
||||||
}
|
}
|
||||||
if (!title) title = "Untitled";
|
if (!title) title = "Untitled";
|
||||||
return title;
|
return title;
|
||||||
|
|
Loading…
Reference in a new issue