summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-10-05 09:37:35 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-10-05 09:37:35 -0700
commitc33b4581c94c71fe0ffc7702efa7f6a4fdac23d2 (patch)
treee33af846978a0bcfa65115bc47496d3aefba75ee /src
parent5a691e8c3f412e8949f34e59debd794444a954fb (diff)
T.P.Shared.splitSentences: don't split after initials.
This improves the man and ms writer output, preventing sentence breaks after initials.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index 7a2fee7ec..7a374102b 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -565,12 +565,16 @@ splitSentences = go . toList
isSentenceEnding t =
case T.unsnoc t of
Just (t',c)
- | c == '.' || c == '!' || c == '?' -> True
+ | c == '.' || c == '!' || c == '?'
+ , not (isInitial t') -> True
| c == ')' || c == ']' || c == '"' || c == '\x201D' ->
case T.unsnoc t' of
- Just (_,d) -> d == '.' || d == '!' || d == '?'
+ Just (t'',d) -> d == '.' || d == '!' || d == '?' &&
+ not (isInitial t'')
_ -> False
_ -> False
+ where
+ isInitial x = T.length x == 1 && T.all isUpper x
-- | Ensure that all identifiers start with a letter,
-- and modify internal links accordingly. (Yes, XML allows an