packages feed

pandoc-crossref 0.3.11.0 → 0.3.12.0

raw patch · 6 files changed

+48/−48 lines, 6 filesdep +microlensdep +microlens-mtldep +microlens-thdep −data-accessordep −data-accessor-templatedep −data-accessor-transformersdep ~pandocPVP ok

version bump matches the API change (PVP)

Dependencies added: microlens, microlens-mtl, microlens-th

Dependencies removed: data-accessor, data-accessor-template, data-accessor-transformers

Dependency ranges changed: pandoc

API changes (from Hackage documentation)

Files

lib-internal/Text/Pandoc/CrossRef/References/Blocks.hs view
@@ -34,8 +34,6 @@ import qualified Data.Text as T import qualified Data.Text.Read as T -import Data.Accessor-import Data.Accessor.Monad.Trans.State import Text.Pandoc.CrossRef.References.Types import Text.Pandoc.CrossRef.Util.Util import Text.Pandoc.CrossRef.Util.Options@@ -43,6 +41,8 @@ import Control.Applicative import Prelude import Data.Default+import Lens.Micro+import Lens.Micro.Mtl  replaceAll :: (Data a) => Options -> a -> WS a replaceAll opts =@@ -83,7 +83,7 @@                  then "sec:"<>label                  else label     unless ("unnumbered" `elem` cls) $ do-      modify curChap $ \cc ->+      modifying curChap $ \cc ->         let ln = length cc             cl i = lookup "label" attrs <|> customHeadingLabel opts n i <|> customLabel opts "sec" i             inc l = let i = fst (last l) + 1 in init l <> [(i, cl i)]@@ -92,13 +92,13 @@                 | otherwise = cc <> take (n-ln-1) (zip [1,1..] $ repeat Nothing) <> [(1,cl 1)]         in cc'       when ("sec:" `T.isPrefixOf` label') $ do-        index  <- get curChap-        modify secRefs $ M.insert label' RefRec {+        index  <- use curChap+        modifying secRefs $ M.insert label' RefRec {           refIndex=index         , refTitle= text'         , refSubfigure = Nothing         }-    cc <- get curChap+    cc <- use curChap     let textCC | numberSections opts                , sectionsDepth opts < 0                || n <= if sectionsDepth opts == 0 then chaptersDepth opts else sectionsDepth opts@@ -127,7 +127,7 @@           $ sortOn (refIndex . snd)           $ filter (not . null . refTitle . snd)           $ M.toList-          $ imgRefs_ st+          $ st^.imgRefs         collectCaps v =               applyTemplate                 (chapPrefix (chapDelim opts) (refIndex v))@@ -139,12 +139,12 @@                   , ("t", caption)                   ]         capt = applyTemplate' vars $ subfigureTemplate opts-    lastRef <- fromJust . M.lookup label <$> get imgRefs-    modify imgRefs $ \old ->+    lastRef <- fromJust . M.lookup label <$> use imgRefs+    modifying imgRefs $ \old ->         M.union           old           (M.map (\v -> v{refIndex = refIndex lastRef, refSubfigure = Just $ refIndex v})-          $ imgRefs_ st)+          $ st^.imgRefs)     case outFormat opts of           f | isLatexFormat f ->             replaceNoRecurse $ Div nullAttr $@@ -395,18 +395,18 @@   = Span nullAttr [math]:ils spanInlines _ x = x -replaceAttr :: Options -> Either T.Text T.Text -> Maybe T.Text -> [Inline] -> Accessor References RefMap -> WS [Inline]+replaceAttr :: Options -> Either T.Text T.Text -> Maybe T.Text -> [Inline] -> Lens References References RefMap RefMap -> WS [Inline] replaceAttr o label refLabel title prop   = do-    chap  <- take (chaptersDepth o) `fmap` get curChap-    prop' <- get prop+    chap  <- take (chaptersDepth o) `fmap` use curChap+    prop' <- use prop     let i = 1+ (M.size . M.filter (\x -> (chap == init (refIndex x)) && isNothing (refSubfigure x)) $ prop')         index = chap <> [(i, refLabel <|> customLabel o ref i)]         ref = either id (T.takeWhile (/=':')) label         label' = either (<> T.pack (':' : show index)) id label     when (M.member label' prop') $       error . T.unpack $ "Duplicate label: " <> label'-    modify prop $ M.insert label' RefRec {+    modifying prop $ M.insert label' RefRec {       refIndex= index     , refTitle= title     , refSubfigure = Nothing
lib-internal/Text/Pandoc/CrossRef/References/List.hs view
@@ -22,7 +22,6 @@ module Text.Pandoc.CrossRef.References.List (listOf) where  import Text.Pandoc.Definition-import Data.Accessor.Monad.Trans.State import Control.Arrow import Data.List import qualified Data.Map as M@@ -31,18 +30,19 @@ import Text.Pandoc.CrossRef.References.Types import Text.Pandoc.CrossRef.Util.Util import Text.Pandoc.CrossRef.Util.Options+import Lens.Micro.Mtl  listOf :: Options -> [Block] -> WS [Block] listOf Options{outFormat=f} x | isLatexFormat f = return x listOf opts (RawBlock fmt "\\listoffigures":xs)   | isLaTeXRawBlockFmt fmt-  = get imgRefs >>= makeList opts lofTitle xs+  = use imgRefs >>= makeList opts lofTitle xs listOf opts (RawBlock fmt "\\listoftables":xs)   | isLaTeXRawBlockFmt fmt-  = get tblRefs >>= makeList opts lotTitle xs+  = use tblRefs >>= makeList opts lotTitle xs listOf opts (RawBlock fmt "\\listoflistings":xs)   | isLaTeXRawBlockFmt fmt-  = get lstRefs >>= makeList opts lolTitle xs+  = use lstRefs >>= makeList opts lolTitle xs listOf _ x = return x  makeList :: Options -> (Options -> [Block]) -> [Block] -> M.Map T.Text RefRec -> WS [Block]
lib-internal/Text/Pandoc/CrossRef/References/Refs.hs view
@@ -32,8 +32,6 @@ import qualified Data.Map as M import Control.Arrow as A -import Data.Accessor-import Data.Accessor.Monad.Trans.State import Text.Pandoc.CrossRef.References.Types import Text.Pandoc.CrossRef.Util.Template import Text.Pandoc.CrossRef.Util.Util@@ -41,6 +39,8 @@ import Control.Applicative import Debug.Trace import Prelude+import Lens.Micro+import Lens.Micro.Mtl  replaceRefs :: Options -> [Inline] -> WS [Inline] replaceRefs opts (Cite cits _:xs)@@ -67,7 +67,7 @@ replaceRefs _ x = return x  -- accessors to state variables-accMap :: M.Map T.Text (Accessor References RefMap)+accMap :: M.Map T.Text ((RefMap -> Const RefMap RefMap) -> References -> Const RefMap References) accMap = M.fromList [("fig:",imgRefs)                     ,("eq:" ,eqnRefs)                     ,("tbl:",tblRefs)@@ -185,7 +185,7 @@ getRefIndex :: T.Text -> Options -> Citation -> WS RefData getRefIndex prefix _opts Citation{citationId=cid,citationSuffix=suf}   = do-    ref <- M.lookup lab <$> get prop+    ref <- M.lookup lab <$> use prop     let sub = refSubfigure <$> ref         idx = refIndex <$> ref         tit = refTitle <$> ref
lib-internal/Text/Pandoc/CrossRef/References/Types.hs view
@@ -25,8 +25,8 @@ import Text.Pandoc.Definition import Control.Monad.State import Data.Default-import Data.Accessor.Template import Data.Text (Text)+import Lens.Micro.TH  type Index = [(Int, Maybe Text)] @@ -38,12 +38,12 @@ type RefMap = M.Map Text RefRec  -- state data type-data References = References { imgRefs_ :: RefMap-                             , eqnRefs_ :: RefMap-                             , tblRefs_ :: RefMap-                             , lstRefs_ :: RefMap-                             , secRefs_ :: RefMap-                             , curChap_ :: Index+data References = References { _imgRefs :: RefMap+                             , _eqnRefs :: RefMap+                             , _tblRefs :: RefMap+                             , _lstRefs :: RefMap+                             , _secRefs :: RefMap+                             , _curChap :: Index                              } deriving (Show, Eq)  --state monad@@ -53,4 +53,4 @@   def = References n n n n n []     where n = M.empty -deriveAccessors ''References+makeLenses ''References
pandoc-crossref.cabal view
@@ -1,13 +1,13 @@ cabal-version: 2.0 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack ----- hash: e117c4fe3ce92561126a6cfd9a8f561d8f78d4bbc5411e58e04e0cdb1b568a3f+-- hash: 4661699925ae4f2bebb7c3d4c729f29850c37104cb97b210f0ea5df5080e7d6d  name:           pandoc-crossref-version:        0.3.11.0+version:        0.3.12.0 synopsis:       Pandoc filter for cross-references description:    pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. category:       Text@@ -138,12 +138,12 @@   build-depends:       base >=4.11 && <5     , containers >=0.1 && <0.7-    , data-accessor >=0.2.2.6 && <0.3.0.0-    , data-accessor-template >=0.2.1.12 && <0.3.0.0-    , data-accessor-transformers >=0.2.1.6 && <0.3.0.0     , data-default >=0.4 && <0.8     , directory >=1 && <1.4     , filepath >=1.1 && <1.5+    , microlens >=0.4.12.0 && <0.5.0.0+    , microlens-mtl >=0.2.0.1 && <0.3.0.0+    , microlens-th >=0.4.3.10 && <0.5.0.0     , mtl >=1.1 && <2.3     , pandoc >=2.10 && <2.15     , pandoc-types >=1.21 && <1.23@@ -163,9 +163,9 @@   ghc-options: -Wall -threaded   build-depends:       base >=4.11 && <5-    , deepseq >=1.4 && <1.5+    , deepseq ==1.4.*     , gitrev >=1.3.1 && <1.4-    , open-browser >=0.2 && <0.3+    , open-browser ==0.2.*     , optparse-applicative >=0.13 && <0.17     , pandoc >=2.10 && <2.15     , pandoc-crossref@@ -208,9 +208,9 @@   build-depends:       base >=4.11 && <5     , containers >=0.1 && <0.7-    , data-accessor >=0.2.2.6 && <0.3.0.0     , data-default >=0.4 && <0.8     , hspec >=2.4.4 && <3+    , microlens >=0.4.12.0 && <0.5.0.0     , mtl >=1.1 && <2.3     , pandoc >=2.10 && <2.15     , pandoc-crossref
test/test-pandoc-crossref.hs view
@@ -18,7 +18,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -} -{-# LANGUAGE FlexibleContexts, CPP, OverloadedStrings #-}+{-# LANGUAGE FlexibleContexts, CPP, OverloadedStrings, RankNTypes #-} import Test.Hspec import Text.Pandoc hiding (getDataFileName) import Text.Pandoc.Builder@@ -33,7 +33,7 @@ import Text.Pandoc.CrossRef.Util.Options import Text.Pandoc.CrossRef.Util.Util import Text.Pandoc.CrossRef.References.Types-import Data.Accessor hiding ((=:))+import Lens.Micro import qualified Text.Pandoc.CrossRef.References.Blocks as References.Blocks import qualified Text.Pandoc.CrossRef.References.Refs as References.Refs import qualified Text.Pandoc.CrossRef.References.List as References.List@@ -183,7 +183,7 @@       it "Labels sections divs" $         testAll (section "Section Header" 1 "section")         (section "Section Header" 1 "section",-          secRefs ^= M.fromList (refRec' "sec:section" 1 "Section Header")+          secRefs .~ M.fromList (refRec' "sec:section" 1 "Section Header")           $ curChap =: [(1,Nothing)])      describe "References.Refs.replaceRefs" $ do@@ -348,11 +348,11 @@ refRec''' :: T.Text -> (Int, Int) -> [(T.Text, RefRec)] refRec''' ref (c,i) = [(ref, RefRec{refIndex=[(c,Nothing), (i,Nothing)],refTitle=toList $ text "",refSubfigure=Nothing})] -testRefs' :: T.Text -> [Int] -> [Int] -> Accessor References (M.Map T.Text RefRec) -> T.Text -> Expectation-testRefs' p l1 l2 prop res = testRefs (para $ citeGen p l1) (setVal prop (refGen p l1 l2) def) (para $ text res)+testRefs' :: T.Text -> [Int] -> [Int] -> Lens' References (M.Map T.Text RefRec) -> T.Text -> Expectation+testRefs' p l1 l2 prop res = testRefs (para $ citeGen p l1) (set prop (refGen p l1 l2) def) (para $ text res) -testRefs'' :: T.Text -> [Int] -> [(Int, Int)] -> Accessor References (M.Map T.Text RefRec) -> T.Text -> Expectation-testRefs'' p l1 l2 prop res = testRefs (para $ citeGen p l1) (setVal prop (refGen' p l1 l2) def) (para $ text res)+testRefs'' :: T.Text -> [Int] -> [(Int, Int)] -> Lens' References (M.Map T.Text RefRec) -> T.Text -> Expectation+testRefs'' p l1 l2 prop res = testRefs (para $ citeGen p l1) (set prop (refGen' p l1 l2) def) (para $ text res)  testAll :: (Eq a, Data a, Show a) => Many a -> (Many a, References) -> Expectation testAll = testState f def@@ -435,5 +435,5 @@ cit r = [defCit{citationId=r}]  infixr 0 =:-(=:) :: Df.Default r => Accessor r a -> a -> r-a =: b = a ^= b $ def+(=:) :: Df.Default r => Lens' r a -> a -> r+a =: b = a .~ b $ def