Leave a spaced dash out of the text of a match that ends before it

This commit is contained in:
dualfroz committed 2026-10-03 01:05:43 +02:00
1 parent 1bb20a37d2
commit 5a4cddfb00
4 files changed
+21 -1

No files matched your search

+4
View File
@@ -93,6 +93,10 @@ const textFromDoc = function (docs, opts) {
const last = docs.at(-1)
if (!last.at(-1).tags.has('Emoticon')) {
text = trimEnd(text)
// removing a spaced dash leaves its space behind
if (!opts.keepSpace) {
text = text.trimEnd()
}
}
// kill end quotations
if (text.endsWith(`'`) && !text.endsWith(`s'`)) {
+4 -1
View File
@@ -4,6 +4,8 @@ import fmts from './_fmts.js'
const isObject = val => {
return Object.prototype.toString.call(val) === '[object Object]'
}
// a dash between two words, like '2025-05-11 - they'
const spacedDash = /^\s+[-—]\s+$/
export default {
/** */
@@ -21,7 +23,8 @@ export default {
}
if (opts.keepEndPunct === undefined && this.pointer) {
const ptr = this.pointer[0]
if (ptr?.[1]) {
const lastTerm = this.docs.at(-1)?.at(-1)
if (ptr?.[1] || spacedDash.test(lastTerm?.post)) {
opts.keepEndPunct = false
} else {
opts.keepEndPunct = true