From f7c47429879f757e08975b5cd003416db00f5568 Mon Sep 17 00:00:00 2001
From: Julian Lam
.*/g, '');
-
- // Strip html
- title = utils.stripHTMLTags(title);
-
- // Split sentences and use only first one
- const sentences = title
- .split(/(\.|\?|!)\s/)
- .reduce((memo, cur, idx, sentences) => {
- if (idx % 2) {
- memo.push(`${sentences[idx - 1]}${cur}`);
- } else if (idx === sentences.length - 1) {
- memo.push(cur);
- }
-
- return memo;
- }, []);
-
- if (sentences.length > 1) {
- title = sentences.shift();
- }
-
- // Truncate down if too long
- if (title.length > meta.config.maximumTitleLength) {
- title = `${title.slice(0, meta.config.maximumTitleLength - 3)}...`;
- }
-
- return title;
-};
-
Helpers.remoteAnchorToLocalProfile = async (content, isMarkdown = false) => {
let anchorRegex;
if (isMarkdown) {
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index ef4abe9add..6ccb2ca209 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -165,7 +165,11 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
// mainPid ok to leave as-is
if (!title) {
- const sentences = tokenizer.sentences(content || sourceContent, { sanitize: true });
+ // Naive pre-processing prior to sbd tokenization
+ let sbdInput = content || sourceContent;
+ sbdInput = sbdInput.replace('
', '
\n'); + + const sentences = tokenizer.sentences(sbdInput, { sanitize: true, newline_boundaries: true }); title = sentences.shift(); }