diff options
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX/Parsing.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/Parsing.hs | 26 |
1 files changed, 26 insertions, 0 deletions
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] + |