jgm / citeproc

CSL citation processing library in Haskell
BSD 2-Clause "Simplified" License
154 stars 16 forks source link

Support for `AuthorInText` and `AuthorOnly` in `CiteprocOptions` #69

Open kjambunathan opened 3 years ago

kjambunathan commented 3 years ago

citeproc has no support for pandoc's AuthorInText.[1][2] It will be good if citeproc implements AuthorInText natively.

The pandoc executable simulates AuthorInText by emitting AuthorOnly and SuppressAuthor in sequence for the associated key.[3] I believe citeproc could do likewise. The consequence of this is that, citeproc will offer AuthorOnly and AuthorInText as two new features, in addition to existing linkCitations, in CiteprocOptions[4].


[1]: CitationItemType of citeproc makes no mention of AuthorInText. So, AuthorInText is not supported by citeproc.

data CitationItemType =
    AuthorOnly      --  e.g., Smith
  | SuppressAuthor  --  e.g., (2000, p. 30)
  | NormalCite      --  e.g., (Smith 2000, p. 30)
  deriving (Show, Eq, Ord)

[2]: CitationMode of pandoc-types supports AuthorInText in additon to SuppressAuthor.

data CitationMode
  = AuthorInText
  | SuppressAuthor
  | NormalCitation
  deriving (Show, Eq, Ord, Read, Typeable, Data, Generic)

[3]: In fromPandocCitations of pandoc simulates AuthorInText by emitting in AuthorOnly and SuppressAuthor in sequence for the associated key.

     in if Pandoc.citationId c == "*"
           then []
           else
             case citationMode c of
                  AuthorInText   -> [ cit{ citationItemType = AuthorOnly
                                         , citationItemSuffix = Nothing }
                                    , cit{ citationItemType =
                                              Citeproc.SuppressAuthor
                                         , citationItemPrefix = Nothing } ]
                  NormalCitation -> [ cit ]
                  Pandoc.SuppressAuthor
                                 -> [ cit{ citationItemType =
                                              Citeproc.SuppressAuthor } ]

[4]: CiteprocOptions ofciteproc`

newtype CiteprocOptions =
  CiteprocOptions
  { linkCitations :: Bool
    --  Create hyperlinks from citations to bibliography entries
  }
  deriving (Show, Eq)
jgm commented 3 years ago

Here we're implementing CSL, which up to now didn't have any concept of an author-only citation. When that changes (and I think there are current discussions on this issue), we can update citeproc accordingly. Until then, simulating the feature seems like the right thing to do.