@@ -135,8 +135,8 @@ processCitations (Pandoc meta bs) = do
135135 Just ls | ls > 1 -> (("line-spacing",T.pack $ show ls):)
136136 _ -> id) $ []
137137 let bibs = mconcat $ map (\(ident, out) ->
138− B.divWith ("ref-" <> ident,["csl-entry"],[]) . B.para $
139− walk (convertQuotes locale) out)
138+ B.divWith ("ref-" <> ident,["csl-entry"],[]) . B.para .
139+ walk (convertQuotes locale) . insertSpace $ out)
140140 (resultBibliography result)
141141 let moveNotes = maybe True truish $
142142 lookupMeta "notes-after-punctuation" meta
@@ -155,6 +155,20 @@ processCitations (Pandoc meta bs) = do
155155 $ cits
156156 return $ Pandoc meta'' $ insertRefs refkvs classes meta'' (B.toList bibs) bs'
157157
158+-- If we have a span.csl-left-margin followed by span.csl-right-inline,
159+-- we insert a space. This ensures that they will be separated by a space,
160+-- even in formats that don't have special handling for the display spans.
161+insertSpace :: Inlines -> Inlines
162+insertSpace ils =
163+ case Seq.viewl (unMany ils) of
164+ (Span ("",["csl-left-margin"],[]) xs) Seq.:< rest ->
165+ case Seq.lookup 0 rest of
166+ Just (Span ("",["csl-right-inline"],[]) _) ->
167+ Many $
168+ Span ("",["csl-left-margin"],[]) (xs ++ [Space]) Seq.<| rest
169+ _ -> ils
170+ _ -> ils
171+
158172getRefsFromBib :: PandocMonad m
159173 => Locale -> (Text -> Bool) -> Text -> m [Reference Inlines]
160174getRefsFromBib locale idpred t = do