aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2021-10-02 23:21:12 -0700
committerJohn MacFarlane <[email protected]>2021-10-02 23:21:22 -0700
commit25bb9ff07b9f9bac301ab9fea519a9ec633b8022 (patch)
tree6baaa32574ebe91b65bc225e2e0290be8a70db8b
parentf36e5e719f478c89ff8495181f8ea6d4db723f02 (diff)
Use the new version of splitSentences in man/ms.
-rw-r--r--src/Text/Pandoc/Writers/Man.hs4
-rw-r--r--src/Text/Pandoc/Writers/Ms.hs7
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs11
-rw-r--r--test/writer.ms13
4 files changed, 14 insertions, 21 deletions
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index 058273250..dc5114172 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -109,10 +109,10 @@ blockToMan :: PandocMonad m
blockToMan _ Null = return empty
blockToMan opts (Div _ bs) = blockListToMan opts bs
blockToMan opts (Plain inlines) =
- inlineListToMan opts inlines
+ splitSentences <$> inlineListToMan opts inlines
blockToMan opts (Para inlines) = do
contents <- inlineListToMan opts inlines
- return $ text ".PP" $$ contents
+ return $ text ".PP" $$ splitSentences contents
blockToMan opts (LineBlock lns) =
blockToMan opts $ linesToPara lns
blockToMan _ b@(RawBlock f str)
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
index c090cd08c..862c5a114 100644
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -143,7 +143,7 @@ blockToMs opts (Div (ident,cls,kvs) bs) = do
setFirstPara
return $ anchor $$ res
blockToMs opts (Plain inlines) =
- inlineListToMs' opts inlines
+ splitSentences <$> inlineListToMs' opts inlines
blockToMs opts (Para [Image attr alt (src,_tit)])
| let ext = takeExtension (T.unpack src) in (ext == ".ps" || ext == ".eps") = do
let (mbW,mbH) = (inPoints opts <$> dimension Width attr,
@@ -156,7 +156,7 @@ blockToMs opts (Para [Image attr alt (src,_tit)])
space <>
doubleQuotes (literal (tshow (floor hp :: Int)))
_ -> empty
- capt <- inlineListToMs' opts alt
+ capt <- splitSentences <$> inlineListToMs' opts alt
return $ nowrap (literal ".PSPIC -C " <>
doubleQuotes (literal (escapeStr opts src)) <>
sizeAttrs) $$
@@ -167,7 +167,8 @@ blockToMs opts (Para inlines) = do
firstPara <- gets stFirstPara
resetFirstPara
contents <- inlineListToMs' opts inlines
- return $ literal (if firstPara then ".LP" else ".PP") $$ contents
+ return $ literal (if firstPara then ".LP" else ".PP") $$
+ splitSentences contents
blockToMs _ b@(RawBlock f str)
| f == Format "ms" = return $ literal str
| otherwise = do
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index de26b5d6c..0ab01ff4d 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -46,7 +46,7 @@ import Data.Maybe (fromMaybe, isNothing)
import Control.Monad (zipWithM)
import Data.Foldable (toList)
import Data.Aeson (ToJSON (..), encode)
-import Data.Char (chr, ord, isSpace, isUpper)
+import Data.Char (chr, ord, isSpace)
import Data.List (groupBy, intersperse, transpose, foldl')
import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
import Data.Text.Conversions (FromText(..))
@@ -565,7 +565,7 @@ splitSentences = go . toList
where
go [] = mempty
go (Text len t : BreakingSpace : xs) =
- if isSentenceEnding t && isSentenceBeginning xs
+ if isSentenceEnding t
then Text len t <> NewLine <> go xs
else Text len t <> BreakingSpace <> go xs
go (x:xs) = x <> go xs
@@ -583,10 +583,3 @@ splitSentences = go . toList
Just (_,d) -> d == '.' || d == '!' || d == '?'
_ -> False
_ -> False
-
- isSentenceBeginning [] = True
- isSentenceBeginning (Text _len t : _) =
- case T.uncons t of
- Just (c,_) -> isUpper c
- _ -> False
- isSentenceBeginning _ = False
diff --git a/test/writer.ms b/test/writer.ms
index fc2e66a34..15eab3090 100644
--- a/test/writer.ms
+++ b/test/writer.ms
@@ -962,13 +962,7 @@ Footnotes
.pdfhref O 1 "Footnotes"
.pdfhref M "footnotes"
.LP
-Here is a footnote reference,\**
-.FS
-Here is the footnote.
-It can go anywhere after the footnote reference.
-It need not be placed at the end of the document.
-.FE
-and another.\**
+Here is a footnote reference,\** and another.\**
.FS
Here\[cq]s the long note.
This one contains multiple blocks.
@@ -985,6 +979,11 @@ list items).
If you want, you can indent every line, but you can also be lazy and just indent
the first line of each block.
.FE
+.FS
+Here is the footnote.
+It can go anywhere after the footnote reference.
+It need not be placed at the end of the document.
+.FE
This should \f[I]not\f[R] be a footnote reference, because it contains a
space.[\[ha]my note] Here is an inline note.\**
.FS