git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Made `\nocite` work.

This adds nocite citations to a metadata field, `nocite`. These will appear in the bibliography but not in the text (unless you use a `$nocite$` variable in your template, of course).

commit22e36e104058b0ea93dbda106374f6c02bbf36d6 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 26 Apr 2014, 12:14 (13 years ago) parent35ea8de
1 file changed+6−3
src/Text/Pandoc/Readers/LaTeX.hs+6−3
src/Text/Pandoc/Readers/LaTeX.hs+6−3
@@ -322,7 +322,8 @@ blockCommands = M.fromList $
322322 ]
323323
324324addMeta :: ToMetaValue a => String -> a -> LP ()
325−addMeta field val = updateState $ setMeta field val
325+addMeta field val = updateState $ \st ->
326+ st{ stateMeta = addMetaField field val $ stateMeta st }
326327
327328setCaption :: Inlines -> LP Blocks
328329setCaption ils = do
@@ -341,7 +342,7 @@ authors = try $ do
341342 -- skip e.g. \vspace{10pt}
342343 auths <- sepBy oneAuthor (controlSeq "and")
343344 char '}'
344− addMeta "authors" (map trimInlines auths)
345+ addMeta "author" (map trimInlines auths)
345346
346347section :: Attr -> Int -> LP Blocks
347348section (ident, classes, kvs) lvl = do
@@ -525,10 +526,12 @@ inlineCommands = M.fromList $
525526 , ("citeauthor", (try (tok *> optional sp *> controlSeq "citetext") *>
526527 complexNatbibCitation AuthorInText)
527528 <|> citation "citeauthor" AuthorInText False)
529+ , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
530+ addMeta "nocite"))
528531 ] ++ map ignoreInlines
529532 -- these commands will be ignored unless --parse-raw is specified,
530533 -- in which case they will appear as raw latex blocks:
531− [ "noindent", "index", "nocite" ]
534+ [ "noindent", "index" ]
532535
533536mkImage :: String -> LP Inlines
534537mkImage src = do