diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-11-16 22:36:10 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-11-16 22:36:10 -0800 |
commit | c9ada73caca108b912d4c1289cffc9a7fcd66ce0 (patch) | |
tree | 1ae6ff8611c2fb90829e8305e81caa5849262ff5 | |
parent | 57102d6ac46e3d8caf4755e46e830a10f1d7517c (diff) | |
download | pandoc-c9ada73caca108b912d4c1289cffc9a7fcd66ce0.tar.gz |
Move getNextNumber from Readers.LaTeX to Readers.LaTeX.Parsing.
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 26 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/Parsing.hs | 26 |
2 files changed, 26 insertions, 26 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 38e2435e3..61c9abe3a 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1923,32 +1923,6 @@ addImageCaption = walkM go return $ Image attr' alt' (src, tit') go x = return x -getNextNumber :: Monad m - => (LaTeXState -> DottedNum) -> LP m DottedNum -getNextNumber getCurrentNum = do - st <- getState - let chapnum = - case sLastHeaderNum st of - DottedNum (n:_) | sHasChapters st -> Just n - _ -> Nothing - return . DottedNum $ - case getCurrentNum st of - DottedNum [m,n] -> - case chapnum of - Just m' | m' == m -> [m, n+1] - | otherwise -> [m', 1] - Nothing -> [1] - -- shouldn't happen - DottedNum [n] -> - case chapnum of - Just m -> [m, 1] - Nothing -> [n + 1] - _ -> - case chapnum of - Just n -> [n, 1] - Nothing -> [1] - - coloredBlock :: PandocMonad m => Text -> LP m Blocks coloredBlock stylename = try $ do skipopts diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs index 09f332bb8..563d32883 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs @@ -77,6 +77,7 @@ module Text.Pandoc.Readers.LaTeX.Parsing , skipopts , rawopt , overlaySpecification + , getNextNumber ) where import Control.Applicative (many, (<|>)) @@ -848,3 +849,28 @@ isFontSizeCommand "huge" = True isFontSizeCommand "Huge" = True isFontSizeCommand _ = False +getNextNumber :: Monad m + => (LaTeXState -> DottedNum) -> LP m DottedNum +getNextNumber getCurrentNum = do + st <- getState + let chapnum = + case sLastHeaderNum st of + DottedNum (n:_) | sHasChapters st -> Just n + _ -> Nothing + return . DottedNum $ + case getCurrentNum st of + DottedNum [m,n] -> + case chapnum of + Just m' | m' == m -> [m, n+1] + | otherwise -> [m', 1] + Nothing -> [1] + -- shouldn't happen + DottedNum [n] -> + case chapnum of + Just m -> [m, 1] + Nothing -> [n + 1] + _ -> + case chapnum of + Just n -> [n, 1] + Nothing -> [1] + |