git.iko.soy/typeable/pandoc
on ff26af5 help sign in
src/Text/Pandoc/Citeproc.hs+15−22
since splitsnapshots
unifiedsplit
@@ -99,7 +99,7 @@ processCitations (Pandoc meta bs) = do
99 let metanocites = lookupMeta "nocite" meta
99 let metanocites = lookupMeta "nocite" meta
100 let Pandoc meta'' bs' =
100 let Pandoc meta'' bs' =
101 maybe id (setMeta "nocite") metanocites .
101 maybe id (setMeta "nocite") metanocites .
102− walk (mvPunct moveNotes locale) .
102+ walk (map capitalizeNoteCitation . mvPunct moveNotes locale) .
103 (if styleIsNoteStyle sopts
103 (if styleIsNoteStyle sopts
104 then walk addNote . walk deNote
104 then walk addNote . walk deNote
105 else id) .
105 else id) .
@@ -564,28 +564,27 @@ extractText (FancyVal x) = toText x
564extractText (NumVal n) = T.pack (show n)
564extractText (NumVal n) = T.pack (show n)
565extractText _ = mempty
565extractText _ = mempty
566
566
567−-- Here we take the Spans with class csl-note that are left
567+capitalizeNoteCitation :: Inline -> Inline
568−-- after deNote has removed nested ones, and convert them
568+capitalizeNoteCitation (Cite cs [Note [Para ils]]) =
569−-- into real notes.
569+ Cite cs
570+ [Note [Para $ B.toList $ addTextCase Nothing CapitalizeFirst
571+ $ B.fromList ils]]
572+capitalizeNoteCitation x = x
573+
570addNote :: Inline -> Inline
574addNote :: Inline -> Inline
571−addNote (Span ("",["csl-note"],[]) ils) =
575+addNote (Span ("",["csl-note"],[]) ils) = Note [Para ils]
572− Note [Para $
573− B.toList . addTextCase Nothing CapitalizeFirst . B.fromList $ ils]
574addNote x = x
576addNote x = x
575
577
576−-- Here we handle citation notes that occur inside footnotes
577−-- or other citation notes, in a note style. We don't want
578−-- notes inside notes, so we convert these to parenthesized
579−-- or comma-separated citations.
580−deNote :: Inline -> Inline
578+deNote :: [Inline] -> [Inline]
579+deNote [] = []
581−deNote (Note bs) =
580+deNote (Note bs:rest) =
582 case bs of
581 case bs of
583 [Para (cit@(Cite (c:_) _) : ils)]
582 [Para (cit@(Cite (c:_) _) : ils)]
584 | citationMode c /= AuthorInText ->
583 | citationMode c /= AuthorInText ->
585 -- if citation is first in note, no need to parenthesize.
584 -- if citation is first in note, no need to parenthesize.
586 Note [Para (walk removeNotes $ cit : walk addParens ils)]
585 Note [Para (walk removeNotes $ cit : walk addParens ils)]
586+ : deNote rest
587− _ -> Note (walk removeNotes . walk addParens $ bs)
587+ _ -> Note (walk removeNotes . walk addParens $ bs) : deNote rest
588−
589 where
588 where
590 addParens [] = []
589 addParens [] = []
591 addParens (Cite (c:cs) ils : zs)
590 addParens (Cite (c:cs) ils : zs)
@@ -595,31 +594,25 @@ deNote (Note bs) =
595 | otherwise
594 | otherwise
596 = Cite (c:cs) (concatMap noteInParens ils) : addParens zs
595 = Cite (c:cs) (concatMap noteInParens ils) : addParens zs
597 addParens (x:xs) = x : addParens xs
596 addParens (x:xs) = x : addParens xs
598−
599 removeNotes (Span ("",["csl-note"],[]) ils) = Span ("",[],[]) ils
597 removeNotes (Span ("",["csl-note"],[]) ils) = Span ("",[],[]) ils
600 removeNotes x = x
598 removeNotes x = x
601−
602 needsPeriod [] = True
599 needsPeriod [] = True
603 needsPeriod (Str t:_) = case T.uncons t of
600 needsPeriod (Str t:_) = case T.uncons t of
604 Nothing -> False
601 Nothing -> False
605 Just (c,_) -> isUpper c
602 Just (c,_) -> isUpper c
606 needsPeriod (Space:zs) = needsPeriod zs
603 needsPeriod (Space:zs) = needsPeriod zs
607 needsPeriod _ = False
604 needsPeriod _ = False
608−
609 noteInParens (Span ("",["csl-note"],[]) ils)
605 noteInParens (Span ("",["csl-note"],[]) ils)
610 = Space : Str "(" :
606 = Space : Str "(" :
611 removeFinalPeriod ils ++ [Str ")"]
607 removeFinalPeriod ils ++ [Str ")"]
612 noteInParens x = [x]
608 noteInParens x = [x]
613−
614 noteAfterComma needsPer (Span ("",["csl-note"],[]) ils)
609 noteAfterComma needsPer (Span ("",["csl-note"],[]) ils)
615− | not (null ils)
616 = Str "," : Space :
610 = Str "," : Space :
617 if needsPer
611 if needsPer
618 then ils
612 then ils
619 else removeFinalPeriod ils
613 else removeFinalPeriod ils
620 noteAfterComma _ x = [x]
614 noteAfterComma _ x = [x]
621−
622−deNote x = x
615+deNote (x:xs) = x : deNote xs
623
616
624-- Note: we can't use dropTextWhileEnd indiscriminately,
617-- Note: we can't use dropTextWhileEnd indiscriminately,
625-- because this would remove the final period on abbreviations like Ibid.
618-- because this would remove the final period on abbreviations like Ibid.
src/Text/Pandoc/Writers/HTML.hs+1−6
@@ -26,13 +26,8 @@ module Text.Pandoc.Writers.HTML (
26 writeSlideous,
26 writeSlideous,
27 writeDZSlides,
27 writeDZSlides,
28 writeRevealJs,
28 writeRevealJs,
29− tagWithAttributes,
29+ tagWithAttributes
30− inlineToHtml,
31− blockToHtml,
32− WriterState(..),
33− defaultWriterState
34 ) where
30 ) where
35−
36import Control.Monad.State.Strict
31import Control.Monad.State.Strict
37import Data.Char (ord)
32import Data.Char (ord)
38import Data.List (intercalate, intersperse, partition, delete, (\\), foldl')
33import Data.List (intercalate, intersperse, partition, delete, (\\), foldl')
test/command/7394.mddeleted−85
@@ -1,85 +0,0 @@
1−```
2−% pandoc -f markdown -t plain --citeproc
3−---
4−csl: command/chicago-fullnote-bibliography.csl
5−references:
6−- author:
7− - family: Wandt
8− given: Manfred
9− edition: 6
10− id: wandt2014ges-sv
11− issued: 2014
12− publisher: Franz Vahlen
13− publisher-place: München
14− title: Gesetzliche schuldverhältnisse
15− title-short: Gesetzl SV
16− type: book
17−- author:
18− - family: Smith
19− given: Zenda
20− edition: 6
21− id: smith2015
22− issued: 2015
23− publisher: Macmillan
24− publisher-place: New York
25− title: A verb and a noun
26− type: book
27−---
28−
29−Hi^[@wandt2014ges-sv.].
30−
31−Hi^[[@wandt2014ges-sv].].
32−
33−Hi^[[See also @wandt2014ges-sv].].
34−
35−Hi^[See also @wandt2014ges-sv.].
36−
37−Hi^[@wandt2014ges-sv [@smith2015].].
38−
39−Hi^[[@wandt2014ges-sv; @smith2015].].
40−
41−Hi [@wandt2014ges-sv].
42−
43−Hi [see also @wandt2014ges-sv].
44−
45−^D
46−Hi[1].
47−
48−Hi[2].
49−
50−Hi[3].
51−
52−Hi[4].
53−
54−Hi[5].
55−
56−Hi[6].
57−
58−Hi.[7]
59−
60−Hi.[8]
61−
62−Smith, Zenda. A Verb and a Noun. 6th ed. New York: Macmillan, 2015.
63−
64−Wandt, Manfred. Gesetzliche Schuldverhältnisse. 6th ed. München: Franz
65−Vahlen, 2014.
66−
67−[1] Manfred Wandt, Gesetzliche Schuldverhältnisse, 6th ed. (München:
68−Franz Vahlen, 2014).
69−
70−[2] Wandt.
71−
72−[3] See also Wandt.
73−
74−[4] See also Wandt.
75−
76−[5] Wandt, Zenda Smith, A Verb and a Noun, 6th ed. (New York: Macmillan,
77−2015).
78−
79−[6] Wandt, Gesetzl SV; Smith, A Verb and a Noun.
80−
81−[7] Wandt, Gesetzl SV.
82−
83−[8] See also Wandt.
84−```
85−