git.iko.soy/typeable/pandoc
on master help sign in
Citeproc: Insert space after csl-left-margin span contents...
810ea6fJohn MacFarlane
src/Text/Pandoc/Citeproc.hs+16−2
@@ -135,8 +135,8 @@ processCitations (Pandoc meta bs) = do
135 Just ls | ls > 1 -> (("line-spacing",T.pack $ show ls):)
135 Just ls | ls > 1 -> (("line-spacing",T.pack $ show ls):)
136 _ -> id) $ []
136 _ -> id) $ []
137 let bibs = mconcat $ map (\(ident, out) ->
137 let bibs = mconcat $ map (\(ident, out) ->
138− B.divWith ("ref-" <> ident,["csl-entry"],[]) . B.para $
138+ B.divWith ("ref-" <> ident,["csl-entry"],[]) . B.para .
139− walk (convertQuotes locale) out)
139+ walk (convertQuotes locale) . insertSpace $ out)
140 (resultBibliography result)
140 (resultBibliography result)
141 let moveNotes = maybe True truish $
141 let moveNotes = maybe True truish $
142 lookupMeta "notes-after-punctuation" meta
142 lookupMeta "notes-after-punctuation" meta
@@ -155,6 +155,20 @@ processCitations (Pandoc meta bs) = do
155 $ cits
155 $ cits
156 return $ Pandoc meta'' $ insertRefs refkvs classes meta'' (B.toList bibs) bs'
156 return $ Pandoc meta'' $ insertRefs refkvs classes meta'' (B.toList bibs) bs'
157
157
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+
158getRefsFromBib :: PandocMonad m
172getRefsFromBib :: PandocMonad m
159 => Locale -> (Text -> Bool) -> Text -> m [Reference Inlines]
173 => Locale -> (Text -> Bool) -> Text -> m [Reference Inlines]
160getRefsFromBib locale idpred t = do
174getRefsFromBib locale idpred t = do
test/command/pandoc-citeproc-327.md+1−1
@@ -43,7 +43,7 @@ I referenced something here^\[1\]^
43
43
44::: {#refs .references .csl-bib-body}
44::: {#refs .references .csl-bib-body}
45::: {#ref-LiLiaoDongWanHaiYuDiQiDongWuCiJiShengChanLiYanJiuJiShengJingGuaYiXingPingJie2017 .csl-entry}
45::: {#ref-LiLiaoDongWanHaiYuDiQiDongWuCiJiShengChanLiYanJiuJiShengJingGuaYiXingPingJie2017 .csl-entry}
46−[\[1\]]{.csl-left-margin}[李轶平, 于旭光, 孙明, 等.
46+[\[1\] ]{.csl-left-margin}[李轶平, 于旭光, 孙明, 等.
47辽东湾海域底栖动物次级生产力研究及生境适宜性评价\[J\]. 水产科学,
47辽东湾海域底栖动物次级生产力研究及生境适宜性评价\[J\]. 水产科学,
482017(06): 728--734.]{.csl-right-inline}
482017(06): 728--734.]{.csl-right-inline}
49:::
49:::
test/command/pandoc-citeproc-386.md+1−1
@@ -28,7 +28,7 @@ references:
28
28
29::: {#refs .references .csl-bib-body line-spacing="2"}
29::: {#refs .references .csl-bib-body line-spacing="2"}
30::: {#ref-ding_metallic_2012 .csl-entry}
30::: {#ref-ding_metallic_2012 .csl-entry}
31−[\[1\]]{.csl-left-margin}[K. Ding, C. Z. Ning, *Light Sci. Appl.*
31+[\[1\] ]{.csl-left-margin}[K. Ding, C. Z. Ning, *Light Sci. Appl.*
32**2012**, *1*, e20.]{.csl-right-inline}
32**2012**, *1*, e20.]{.csl-right-inline}
33:::
33:::
34:::
34:::
test/command/pandoc-citeproc-ieee.md+3−3
@@ -88,17 +88,17 @@ References {#references .unnumbered}
88
88
89::: {#refs .references .csl-bib-body}
89::: {#refs .references .csl-bib-body}
90::: {#ref-item1 .csl-entry}
90::: {#ref-item1 .csl-entry}
91−[\[1\]]{.csl-left-margin}[J. Doe, *First book*. Cambridge: Cambridge
91+[\[1\] ]{.csl-left-margin}[J. Doe, *First book*. Cambridge: Cambridge
92University Press, 2005.]{.csl-right-inline}
92University Press, 2005.]{.csl-right-inline}
93:::
93:::
94
94
95::: {#ref-item2 .csl-entry}
95::: {#ref-item2 .csl-entry}
96−[\[2\]]{.csl-left-margin}[J. Doe, "Article," *Journal of Generic
96+[\[2\] ]{.csl-left-margin}[J. Doe, "Article," *Journal of Generic
97Studies*, vol. 6, pp. 33--34, 2006.]{.csl-right-inline}
97Studies*, vol. 6, pp. 33--34, 2006.]{.csl-right-inline}
98:::
98:::
99
99
100::: {#ref-пункт3 .csl-entry}
100::: {#ref-пункт3 .csl-entry}
101−[\[3\]]{.csl-left-margin}[J. Doe and J. Roe, "Why water is wet," in
101+[\[3\] ]{.csl-left-margin}[J. Doe and J. Roe, "Why water is wet," in
102*Third book*, S. Smith, Ed. Oxford: Oxford University Press,
102*Third book*, S. Smith, Ed. Oxford: Oxford University Press,
1032007.]{.csl-right-inline}
1032007.]{.csl-right-inline}
104:::
104:::