@@ -532,7 +532,9 @@ deNote (Note bs:rest) =
532532 = Cite cs (concatMap noteInParens ils) : go zs
533533 go (x:xs) = x : go xs
534534 needsPeriod [] = True
535− needsPeriod (Str t:_) = not (T.null t) && isUpper (T.head t)
535+ needsPeriod (Str t:_) = case T.uncons t of
536+ Nothing -> False
537+ Just (c,_) -> isUpper c
536538 needsPeriod (Space:zs) = needsPeriod zs
537539 needsPeriod _ = False
538540 noteInParens (Note bs')
@@ -555,6 +557,25 @@ deNote (x:xs) = x : deNote xs
555557removeFinalPeriod :: [Inline] -> [Inline]
556558removeFinalPeriod ils =
557559 case lastMay ils of
560+ Just (Span attr ils')
561+ -> initSafe ils ++ [Span attr (removeFinalPeriod ils')]
562+ Just (Emph ils')
563+ -> initSafe ils ++ [Emph (removeFinalPeriod ils')]
564+ Just (Strong ils')
565+ -> initSafe ils ++ [Strong (removeFinalPeriod ils')]
566+ Just (SmallCaps ils')
567+ -> initSafe ils ++ [SmallCaps (removeFinalPeriod ils')]
558568 Just (Str t)
559569 | T.takeEnd 1 t == "." -> initSafe ils ++ [Str (T.dropEnd 1 t)]
570+ | isRightQuote (T.takeEnd 1 t)
571+ -> removeFinalPeriod
572+ (initSafe ils ++ [Str tInit | not (T.null tInit)]) ++ [Str tEnd]
573+ where
574+ tEnd = T.takeEnd 1 t
575+ tInit = T.dropEnd 1 t
560576 _ -> ils
577+ where
578+ isRightQuote "\8221" = True
579+ isRightQuote "\8217" = True
580+ isRightQuote "\187" = True
581+ isRightQuote _ = False