git.iko.soy/typeable/pandoc
on master help sign in
Factor out T.P.Readers.LaTeX.Citation.
commit2faa57e8e96d9905676e30f62d34c06b074acf76 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 28 Feb 2021, 09:12 (6 years ago) parent08231f5
4 files changed+232−186
pandoc.cabal+1 src/Text/Pandoc/Readers/LaTeX.hs+16−186 src/Text/Pandoc/Readers/LaTeX/Citation.hs+210 src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5
pandoc.cabal+1
@@ -631,6 +631,7 @@ library
631631 Text.Pandoc.Readers.LaTeX.Lang,
632632 Text.Pandoc.Readers.LaTeX.SIunitx,
633633 Text.Pandoc.Readers.LaTeX.Accent,
634+ Text.Pandoc.Readers.LaTeX.Citation,
634635 Text.Pandoc.Readers.LaTeX.Table,
635636 Text.Pandoc.Readers.Odt.Base,
636637 Text.Pandoc.Readers.Odt.Namespaces,
src/Text/Pandoc/Readers/LaTeX.hs+16−186
@@ -56,6 +56,7 @@ import Text.Pandoc.Readers.LaTeX.Types (ExpansionPoint (..), Macro (..),
5656 ArgSpec (..), Tok (..), TokType (..))
5757import Text.Pandoc.Readers.LaTeX.Parsing
5858import Text.Pandoc.Readers.LaTeX.Accent (accentCommands)
59+import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
5960import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
6061import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
6162 babelLangToBCP47)
@@ -169,7 +170,7 @@ rawLaTeXInline = do
169170 let toks = tokenize "source" inp
170171 raw <- snd <$>
171172 ( rawLaTeXParser toks True
172− (mempty <$ (controlSeq "input" >> skipMany opt >> braced))
173+ (mempty <$ (controlSeq "input" >> skipMany rawopt >> braced))
173174 inlines
174175 <|> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')
175176 inlines
@@ -311,7 +312,7 @@ blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
311312blockquote cvariant mblang = do
312313 citepar <- if cvariant
313314 then (\xs -> para (cite xs mempty))
314− <$> cites NormalCitation False
315+ <$> cites inline NormalCitation False
315316 else option mempty $ para <$> bracketed inline
316317 let lang = mblang >>= babelLangToBCP47
317318 let langdiv = case lang of
@@ -425,116 +426,6 @@ pDollarsMath n = do
425426 else mzero
426427 _ -> (tk :) <$> pDollarsMath n
427428
428−-- citations
429−
430−addPrefix :: [Inline] -> [Citation] -> [Citation]
431−addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks
432−addPrefix _ _ = []
433−
434−addSuffix :: [Inline] -> [Citation] -> [Citation]
435−addSuffix s ks@(_:_) =
436− let k = last ks
437− in init ks ++ [k {citationSuffix = citationSuffix k ++ s}]
438−addSuffix _ _ = []
439−
440−simpleCiteArgs :: PandocMonad m => LP m [Citation]
441−simpleCiteArgs = try $ do
442− first <- optionMaybe $ toList <$> opt
443− second <- optionMaybe $ toList <$> opt
444− keys <- try $ bgroup *> manyTill citationLabel egroup
445− let (pre, suf) = case (first , second ) of
446− (Just s , Nothing) -> (mempty, s )
447− (Just s , Just t ) -> (s , t )
448− _ -> (mempty, mempty)
449− conv k = Citation { citationId = k
450− , citationPrefix = []
451− , citationSuffix = []
452− , citationMode = NormalCitation
453− , citationHash = 0
454− , citationNoteNum = 0
455− }
456− return $ addPrefix pre $ addSuffix suf $ map conv keys
457−
458−citationLabel :: PandocMonad m => LP m Text
459−citationLabel = do
460− sp
461− untokenize <$>
462− (many1 (satisfyTok isWordTok <|> symbolIn bibtexKeyChar)
463− <* sp
464− <* optional (symbol ',')
465− <* sp)
466− where bibtexKeyChar = ".:;?!`'()/*@_+=-&[]" :: [Char]
467−
468−cites :: PandocMonad m => CitationMode -> Bool -> LP m [Citation]
469−cites mode multi = try $ do
470− cits <- if multi
471− then do
472− multiprenote <- optionMaybe $ toList <$> paropt
473− multipostnote <- optionMaybe $ toList <$> paropt
474− let (pre, suf) = case (multiprenote, multipostnote) of
475− (Just s , Nothing) -> (mempty, s)
476− (Nothing , Just t) -> (mempty, t)
477− (Just s , Just t ) -> (s, t)
478− _ -> (mempty, mempty)
479− tempCits <- many1 simpleCiteArgs
480− case tempCits of
481− (k:ks) -> case ks of
482− (_:_) -> return $ (addMprenote pre k : init ks) ++
483− [addMpostnote suf (last ks)]
484− _ -> return [addMprenote pre (addMpostnote suf k)]
485− _ -> return [[]]
486− else count 1 simpleCiteArgs
487− let cs = concat cits
488− return $ case mode of
489− AuthorInText -> case cs of
490− (c:rest) -> c {citationMode = mode} : rest
491− [] -> []
492− _ -> map (\a -> a {citationMode = mode}) cs
493− where mprenote (k:ks) = (k:ks) ++ [Space]
494− mprenote _ = mempty
495− mpostnote (k:ks) = [Str ",", Space] ++ (k:ks)
496− mpostnote _ = mempty
497− addMprenote mpn (k:ks) =
498− let mpnfinal = case citationPrefix k of
499− (_:_) -> mprenote mpn
500− _ -> mpn
501− in addPrefix mpnfinal (k:ks)
502− addMprenote _ _ = []
503− addMpostnote = addSuffix . mpostnote
504−
505−citation :: PandocMonad m => Text -> CitationMode -> Bool -> LP m Inlines
506−citation name mode multi = do
507− (c,raw) <- withRaw $ cites mode multi
508− return $ cite c (rawInline "latex" $ "\\" <> name <> untokenize raw)
509−
510−handleCitationPart :: Inlines -> [Citation]
511−handleCitationPart ils =
512− let isCite Cite{} = True
513− isCite _ = False
514− (pref, rest) = break isCite (toList ils)
515− in case rest of
516− (Cite cs _:suff) -> addPrefix pref $ addSuffix suff cs
517− _ -> []
518−
519−complexNatbibCitation :: PandocMonad m => CitationMode -> LP m Inlines
520−complexNatbibCitation mode = try $ do
521− (cs, raw) <-
522− withRaw $ concat <$> do
523− bgroup
524− items <- mconcat <$>
525− many1 (notFollowedBy (symbol ';') >> inline)
526− `sepBy1` symbol ';'
527− egroup
528− return $ map handleCitationPart items
529− case cs of
530− [] -> mzero
531− (c:cits) -> return $ cite (c{ citationMode = mode }:cits)
532− (rawInline "latex" $ "\\citetext" <> untokenize raw)
533−
534−inNote :: Inlines -> Inlines
535−inNote ils =
536− note $ para $ ils <> str "."
537−
538429inlineCommand' :: PandocMonad m => LP m Inlines
539430inlineCommand' = try $ do
540431 Tok _ (CtrlSeq name) cmd <- anyControlSeq
@@ -553,19 +444,6 @@ inlineCommand' = try $ do
553444tok :: PandocMonad m => LP m Inlines
554445tok = tokWith inline
555446
556−opt :: PandocMonad m => LP m Inlines
557−opt = do
558− toks <- try (sp *> bracketedToks <* sp)
559− -- now parse the toks as inlines
560− st <- getState
561− parsed <- runParserT (mconcat <$> many inline) st "bracketed option" toks
562− case parsed of
563− Right result -> return result
564− Left e -> throwError $ PandocParsecError (untokenize toks) e
565−
566−paropt :: PandocMonad m => LP m Inlines
567−paropt = parenWrapped inline
568−
569447inBrackets :: Inlines -> Inlines
570448inBrackets x = str "[" <> x <> str "]"
571449
@@ -629,6 +507,7 @@ inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
629507inlineCommands =
630508 M.union inlineLanguageCommands $
631509 M.union (accentCommands tok) $
510+ M.union (citationCommands inline) $
632511 M.fromList
633512 [ ("emph", extractSpaces emph <$> tok)
634513 , ("textit", extractSpaces emph <$> tok)
@@ -703,7 +582,7 @@ inlineCommands =
703582 , ("/", pure mempty) -- italic correction
704583 , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState
705584 guard $ not inTableCell
706− optional opt
585+ optional rawopt
707586 spaces))
708587 , (",", lit "\8198")
709588 , ("@", pure mempty)
@@ -761,61 +640,6 @@ inlineCommands =
761640 , ("proofname", doTerm Translations.Proof)
762641 , ("glossaryname", doTerm Translations.Glossary)
763642 , ("lstlistingname", doTerm Translations.Listing)
764− , ("cite", citation "cite" NormalCitation False)
765− , ("Cite", citation "Cite" NormalCitation False)
766− , ("citep", citation "citep" NormalCitation False)
767− , ("citep*", citation "citep*" NormalCitation False)
768− , ("citeal", citation "citeal" NormalCitation False)
769− , ("citealp", citation "citealp" NormalCitation False)
770− , ("citealp*", citation "citealp*" NormalCitation False)
771− , ("autocite", citation "autocite" NormalCitation False)
772− , ("smartcite", citation "smartcite" NormalCitation False)
773− , ("footcite", inNote <$> citation "footcite" NormalCitation False)
774− , ("parencite", citation "parencite" NormalCitation False)
775− , ("supercite", citation "supercite" NormalCitation False)
776− , ("footcitetext", inNote <$> citation "footcitetext" NormalCitation False)
777− , ("citeyearpar", citation "citeyearpar" SuppressAuthor False)
778− , ("citeyear", citation "citeyear" SuppressAuthor False)
779− , ("autocite*", citation "autocite*" SuppressAuthor False)
780− , ("cite*", citation "cite*" SuppressAuthor False)
781− , ("parencite*", citation "parencite*" SuppressAuthor False)
782− , ("textcite", citation "textcite" AuthorInText False)
783− , ("citet", citation "citet" AuthorInText False)
784− , ("citet*", citation "citet*" AuthorInText False)
785− , ("citealt", citation "citealt" AuthorInText False)
786− , ("citealt*", citation "citealt*" AuthorInText False)
787− , ("textcites", citation "textcites" AuthorInText True)
788− , ("cites", citation "cites" NormalCitation True)
789− , ("autocites", citation "autocites" NormalCitation True)
790− , ("footcites", inNote <$> citation "footcites" NormalCitation True)
791− , ("parencites", citation "parencites" NormalCitation True)
792− , ("supercites", citation "supercites" NormalCitation True)
793− , ("footcitetexts", inNote <$> citation "footcitetexts" NormalCitation True)
794− , ("Autocite", citation "Autocite" NormalCitation False)
795− , ("Smartcite", citation "Smartcite" NormalCitation False)
796− , ("Footcite", inNote <$> citation "Footcite" NormalCitation False)
797− , ("Parencite", citation "Parencite" NormalCitation False)
798− , ("Supercite", citation "Supercite" NormalCitation False)
799− , ("Footcitetext", inNote <$> citation "Footcitetext" NormalCitation False)
800− , ("Citeyearpar", citation "Citeyearpar" SuppressAuthor False)
801− , ("Citeyear", citation "Citeyear" SuppressAuthor False)
802− , ("Autocite*", citation "Autocite*" SuppressAuthor False)
803− , ("Cite*", citation "Cite*" SuppressAuthor False)
804− , ("Parencite*", citation "Parencite*" SuppressAuthor False)
805− , ("Textcite", citation "Textcite" AuthorInText False)
806− , ("Textcites", citation "Textcites" AuthorInText True)
807− , ("Cites", citation "Cites" NormalCitation True)
808− , ("Autocites", citation "Autocites" NormalCitation True)
809− , ("Footcites", inNote <$> citation "Footcites" NormalCitation True)
810− , ("Parencites", citation "Parencites" NormalCitation True)
811− , ("Supercites", citation "Supercites" NormalCitation True)
812− , ("Footcitetexts", inNote <$> citation "Footcitetexts" NormalCitation True)
813− , ("citetext", complexNatbibCitation NormalCitation)
814− , ("citeauthor", (try (tok *> sp *> controlSeq "citetext") *>
815− complexNatbibCitation AuthorInText)
816− <|> citation "citeauthor" AuthorInText False)
817− , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
818− addMeta "nocite"))
819643 , ("hyperlink", hyperlink)
820644 , ("hypertarget", hypertargetInline)
821645 -- glossaries package
@@ -918,7 +742,7 @@ inlineCommands =
918742
919743lettrine :: PandocMonad m => LP m Inlines
920744lettrine = do
921− optional opt
745+ optional rawopt
922746 x <- tok
923747 y <- tok
924748 return $ extractSpaces (spanWith ("",["lettrine"],[])) x <> smallcaps y
@@ -1168,6 +992,16 @@ inline = (mempty <$ comment)
1168992inlines :: PandocMonad m => LP m Inlines
1169993inlines = mconcat <$> many inline
1170994
995+opt :: PandocMonad m => LP m Inlines
996+opt = do
997+ toks <- try (sp *> bracketedToks <* sp)
998+ -- now parse the toks as inlines
999+ st <- getState
1000+ parsed <- runParserT (mconcat <$> many inline) st "bracketed option" toks
1001+ case parsed of
1002+ Right result -> return result
1003+ Left e -> throwError $ PandocParsecError (untokenize toks) e
1004+
11711005-- block elements:
11721006
11731007preamble :: PandocMonad m => LP m Blocks
@@ -1261,10 +1095,6 @@ insertIncluded defaultExtension f' = do
12611095 getInput >>= setInput . (tokenize f contents ++)
12621096 updateState dropLatestIncludeFile
12631097
1264−addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> LP m ()
1265−addMeta field val = updateState $ \st ->
1266− st{ sMeta = addMetaField field val $ sMeta st }
1267−
12681098authors :: PandocMonad m => LP m ()
12691099authors = try $ do
12701100 bgroup
src/Text/Pandoc/Readers/LaTeX/Citation.hsnew file+210
@@ -0,0 +1,210 @@
1+{-# LANGUAGE ScopedTypeVariables #-}
2+{-# LANGUAGE OverloadedStrings #-}
3+module Text.Pandoc.Readers.LaTeX.Citation
4+ ( citationCommands
5+ , cites
6+ )
7+where
8+
9+import Text.Pandoc.Class
10+import Text.Pandoc.Readers.LaTeX.Parsing
11+import Text.Pandoc.Builder as B
12+import qualified Data.Map as M
13+import Data.Text (Text)
14+import Control.Applicative ((<|>), optional, many)
15+import Control.Monad (mzero)
16+import Control.Monad.Trans (lift)
17+import Control.Monad.Except (throwError)
18+import Text.Pandoc.Error (PandocError(PandocParsecError))
19+import Text.Pandoc.Parsing hiding (blankline, many, mathDisplay, mathInline,
20+ optional, space, spaces, withRaw, (<|>))
21+
22+citationCommands :: PandocMonad m => LP m Inlines -> M.Map Text (LP m Inlines)
23+citationCommands inline =
24+ let citation = citationWith inline
25+ tok = spaces *> grouped inline
26+ in M.fromList
27+ [ ("cite", citation "cite" NormalCitation False)
28+ , ("Cite", citation "Cite" NormalCitation False)
29+ , ("citep", citation "citep" NormalCitation False)
30+ , ("citep*", citation "citep*" NormalCitation False)
31+ , ("citeal", citation "citeal" NormalCitation False)
32+ , ("citealp", citation "citealp" NormalCitation False)
33+ , ("citealp*", citation "citealp*" NormalCitation False)
34+ , ("autocite", citation "autocite" NormalCitation False)
35+ , ("smartcite", citation "smartcite" NormalCitation False)
36+ , ("footcite", inNote <$> citation "footcite" NormalCitation False)
37+ , ("parencite", citation "parencite" NormalCitation False)
38+ , ("supercite", citation "supercite" NormalCitation False)
39+ , ("footcitetext", inNote <$> citation "footcitetext" NormalCitation False)
40+ , ("citeyearpar", citation "citeyearpar" SuppressAuthor False)
41+ , ("citeyear", citation "citeyear" SuppressAuthor False)
42+ , ("autocite*", citation "autocite*" SuppressAuthor False)
43+ , ("cite*", citation "cite*" SuppressAuthor False)
44+ , ("parencite*", citation "parencite*" SuppressAuthor False)
45+ , ("textcite", citation "textcite" AuthorInText False)
46+ , ("citet", citation "citet" AuthorInText False)
47+ , ("citet*", citation "citet*" AuthorInText False)
48+ , ("citealt", citation "citealt" AuthorInText False)
49+ , ("citealt*", citation "citealt*" AuthorInText False)
50+ , ("textcites", citation "textcites" AuthorInText True)
51+ , ("cites", citation "cites" NormalCitation True)
52+ , ("autocites", citation "autocites" NormalCitation True)
53+ , ("footcites", inNote <$> citation "footcites" NormalCitation True)
54+ , ("parencites", citation "parencites" NormalCitation True)
55+ , ("supercites", citation "supercites" NormalCitation True)
56+ , ("footcitetexts", inNote <$> citation "footcitetexts" NormalCitation True)
57+ , ("Autocite", citation "Autocite" NormalCitation False)
58+ , ("Smartcite", citation "Smartcite" NormalCitation False)
59+ , ("Footcite", inNote <$> citation "Footcite" NormalCitation False)
60+ , ("Parencite", citation "Parencite" NormalCitation False)
61+ , ("Supercite", citation "Supercite" NormalCitation False)
62+ , ("Footcitetext", inNote <$> citation "Footcitetext" NormalCitation False)
63+ , ("Citeyearpar", citation "Citeyearpar" SuppressAuthor False)
64+ , ("Citeyear", citation "Citeyear" SuppressAuthor False)
65+ , ("Autocite*", citation "Autocite*" SuppressAuthor False)
66+ , ("Cite*", citation "Cite*" SuppressAuthor False)
67+ , ("Parencite*", citation "Parencite*" SuppressAuthor False)
68+ , ("Textcite", citation "Textcite" AuthorInText False)
69+ , ("Textcites", citation "Textcites" AuthorInText True)
70+ , ("Cites", citation "Cites" NormalCitation True)
71+ , ("Autocites", citation "Autocites" NormalCitation True)
72+ , ("Footcites", inNote <$> citation "Footcites" NormalCitation True)
73+ , ("Parencites", citation "Parencites" NormalCitation True)
74+ , ("Supercites", citation "Supercites" NormalCitation True)
75+ , ("Footcitetexts", inNote <$> citation "Footcitetexts" NormalCitation True)
76+ , ("citetext", complexNatbibCitation inline NormalCitation)
77+ , ("citeauthor", (try (tok *> sp *> controlSeq "citetext") *>
78+ complexNatbibCitation inline AuthorInText)
79+ <|> citation "citeauthor" AuthorInText False)
80+ , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
81+ addMeta "nocite"))
82+ ]
83+
84+-- citations
85+
86+addPrefix :: [Inline] -> [Citation] -> [Citation]
87+addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks
88+addPrefix _ _ = []
89+
90+addSuffix :: [Inline] -> [Citation] -> [Citation]
91+addSuffix s ks@(_:_) =
92+ let k = last ks
93+ in init ks ++ [k {citationSuffix = citationSuffix k ++ s}]
94+addSuffix _ _ = []
95+
96+simpleCiteArgs :: forall m . PandocMonad m => LP m Inlines -> LP m [Citation]
97+simpleCiteArgs inline = try $ do
98+ first <- optionMaybe $ toList <$> opt
99+ second <- optionMaybe $ toList <$> opt
100+ keys <- try $ bgroup *> manyTill citationLabel egroup
101+ let (pre, suf) = case (first , second ) of
102+ (Just s , Nothing) -> (mempty, s )
103+ (Just s , Just t ) -> (s , t )
104+ _ -> (mempty, mempty)
105+ conv k = Citation { citationId = k
106+ , citationPrefix = []
107+ , citationSuffix = []
108+ , citationMode = NormalCitation
109+ , citationHash = 0
110+ , citationNoteNum = 0
111+ }
112+ return $ addPrefix pre $ addSuffix suf $ map conv keys
113+ where
114+ opt :: PandocMonad m => LP m Inlines
115+ opt = do
116+ toks <- try (sp *> bracketedToks <* sp)
117+ -- now parse the toks as inlines
118+ st <- getState
119+ parsed <- lift $
120+ runParserT (mconcat <$> many inline) st "bracketed option" toks
121+ case parsed of
122+ Right result -> return result
123+ Left e -> throwError $ PandocParsecError (untokenize toks) e
124+
125+
126+
127+citationLabel :: PandocMonad m => LP m Text
128+citationLabel = do
129+ sp
130+ untokenize <$>
131+ (many1 (satisfyTok isWordTok <|> symbolIn bibtexKeyChar)
132+ <* sp
133+ <* optional (symbol ',')
134+ <* sp)
135+ where bibtexKeyChar = ".:;?!`'()/*@_+=-&[]" :: [Char]
136+
137+cites :: PandocMonad m
138+ => LP m Inlines -> CitationMode -> Bool -> LP m [Citation]
139+cites inline mode multi = try $ do
140+ let paropt = parenWrapped inline
141+ cits <- if multi
142+ then do
143+ multiprenote <- optionMaybe $ toList <$> paropt
144+ multipostnote <- optionMaybe $ toList <$> paropt
145+ let (pre, suf) = case (multiprenote, multipostnote) of
146+ (Just s , Nothing) -> (mempty, s)
147+ (Nothing , Just t) -> (mempty, t)
148+ (Just s , Just t ) -> (s, t)
149+ _ -> (mempty, mempty)
150+ tempCits <- many1 $ simpleCiteArgs inline
151+ case tempCits of
152+ (k:ks) -> case ks of
153+ (_:_) -> return $ (addMprenote pre k : init ks) ++
154+ [addMpostnote suf (last ks)]
155+ _ -> return [addMprenote pre (addMpostnote suf k)]
156+ _ -> return [[]]
157+ else count 1 $ simpleCiteArgs inline
158+ let cs = concat cits
159+ return $ case mode of
160+ AuthorInText -> case cs of
161+ (c:rest) -> c {citationMode = mode} : rest
162+ [] -> []
163+ _ -> map (\a -> a {citationMode = mode}) cs
164+ where mprenote (k:ks) = (k:ks) ++ [Space]
165+ mprenote _ = mempty
166+ mpostnote (k:ks) = [Str ",", Space] ++ (k:ks)
167+ mpostnote _ = mempty
168+ addMprenote mpn (k:ks) =
169+ let mpnfinal = case citationPrefix k of
170+ (_:_) -> mprenote mpn
171+ _ -> mpn
172+ in addPrefix mpnfinal (k:ks)
173+ addMprenote _ _ = []
174+ addMpostnote = addSuffix . mpostnote
175+
176+citationWith :: PandocMonad m
177+ => LP m Inlines -> Text -> CitationMode -> Bool -> LP m Inlines
178+citationWith inline name mode multi = do
179+ (c,raw) <- withRaw $ cites inline mode multi
180+ return $ cite c (rawInline "latex" $ "\\" <> name <> untokenize raw)
181+
182+handleCitationPart :: Inlines -> [Citation]
183+handleCitationPart ils =
184+ let isCite Cite{} = True
185+ isCite _ = False
186+ (pref, rest) = break isCite (toList ils)
187+ in case rest of
188+ (Cite cs _:suff) -> addPrefix pref $ addSuffix suff cs
189+ _ -> []
190+
191+complexNatbibCitation :: PandocMonad m
192+ => LP m Inlines -> CitationMode -> LP m Inlines
193+complexNatbibCitation inline mode = try $ do
194+ (cs, raw) <-
195+ withRaw $ concat <$> do
196+ bgroup
197+ items <- mconcat <$>
198+ many1 (notFollowedBy (symbol ';') >> inline)
199+ `sepBy1` symbol ';'
200+ egroup
201+ return $ map handleCitationPart items
202+ case cs of
203+ [] -> mzero
204+ (c:cits) -> return $ cite (c{ citationMode = mode }:cits)
205+ (rawInline "latex" $ "\\citetext" <> untokenize raw)
206+
207+inNote :: Inlines -> Inlines
208+inNote ils =
209+ note $ para $ ils <> str "."
210+
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+5
@@ -85,6 +85,7 @@ module Text.Pandoc.Readers.LaTeX.Parsing
8585 , setCaption
8686 , resetCaption
8787 , env
88+ , addMeta
8889 ) where
8990
9091import Control.Applicative (many, (<|>))
@@ -947,3 +948,7 @@ tokWith inlineParser = try $ spaces >>
947948 where singleChar' = do
948949 Tok _ _ t <- singleChar
949950 return $ str t
951+
952+addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> LP m ()
953+addMeta field val = updateState $ \st ->
954+ st{ sMeta = addMetaField field val $ sMeta st }