git.iko.soy/typeable/pandoc
on master help sign in
Move getNextNumber from Readers.LaTeX to Readers.LaTeX.Parsing.
commitc9ada73caca108b912d4c1289cffc9a7fcd66ce0 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 16 Nov 2020, 22:36 (6 years ago) parent57102d6
2 files changed+26−26
src/Text/Pandoc/Readers/LaTeX.hs−26 src/Text/Pandoc/Readers/LaTeX/Parsing.hs+26
src/Text/Pandoc/Readers/LaTeX.hs−26
@@ -1923,32 +1923,6 @@ addImageCaption = walkM go
19231923 return $ Image attr' alt' (src, tit')
19241924 go x = return x
19251925
1926−getNextNumber :: Monad m
1927− => (LaTeXState -> DottedNum) -> LP m DottedNum
1928−getNextNumber getCurrentNum = do
1929− st <- getState
1930− let chapnum =
1931− case sLastHeaderNum st of
1932− DottedNum (n:_) | sHasChapters st -> Just n
1933− _ -> Nothing
1934− return . DottedNum $
1935− case getCurrentNum st of
1936− DottedNum [m,n] ->
1937− case chapnum of
1938− Just m' | m' == m -> [m, n+1]
1939− | otherwise -> [m', 1]
1940− Nothing -> [1]
1941− -- shouldn't happen
1942− DottedNum [n] ->
1943− case chapnum of
1944− Just m -> [m, 1]
1945− Nothing -> [n + 1]
1946− _ ->
1947− case chapnum of
1948− Just n -> [n, 1]
1949− Nothing -> [1]
1950−
1951−
19521926coloredBlock :: PandocMonad m => Text -> LP m Blocks
19531927coloredBlock stylename = try $ do
19541928 skipopts
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+26
@@ -77,6 +77,7 @@ module Text.Pandoc.Readers.LaTeX.Parsing
7777 , skipopts
7878 , rawopt
7979 , overlaySpecification
80+ , getNextNumber
8081 ) where
8182
8283import Control.Applicative (many, (<|>))
@@ -848,3 +849,28 @@ isFontSizeCommand "huge" = True
848849isFontSizeCommand "Huge" = True
849850isFontSizeCommand _ = False
850851
852+getNextNumber :: Monad m
853+ => (LaTeXState -> DottedNum) -> LP m DottedNum
854+getNextNumber getCurrentNum = do
855+ st <- getState
856+ let chapnum =
857+ case sLastHeaderNum st of
858+ DottedNum (n:_) | sHasChapters st -> Just n
859+ _ -> Nothing
860+ return . DottedNum $
861+ case getCurrentNum st of
862+ DottedNum [m,n] ->
863+ case chapnum of
864+ Just m' | m' == m -> [m, n+1]
865+ | otherwise -> [m', 1]
866+ Nothing -> [1]
867+ -- shouldn't happen
868+ DottedNum [n] ->
869+ case chapnum of
870+ Just m -> [m, 1]
871+ Nothing -> [n + 1]
872+ _ ->
873+ case chapnum of
874+ Just n -> [n, 1]
875+ Nothing -> [1]
876+