pandoc-crossref 0.3.18.1 → 0.3.18.2
raw patch · 27 files changed
+193/−67 lines, 27 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- lib-internal/Text/Pandoc/CrossRef/References/Blocks/Header.hs +2/−0
- lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs +3/−1
- lib-internal/Text/Pandoc/CrossRef/References/Blocks/Util.hs +2/−0
- lib-internal/Text/Pandoc/CrossRef/References/List.hs +3/−3
- lib-internal/Text/Pandoc/CrossRef/References/Types.hs +4/−1
- pandoc-crossref.cabal +4/−1
- test/m2m/delim/expect.tex +5/−5
- test/m2m/eqnBlockTemplate/expect.tex +1/−1
- test/m2m/eqnDisplayTemplate/expect.tex +1/−1
- test/m2m/eqnInlineTableTemplate/expect.tex +1/−1
- test/m2m/eqnInlineTemplate/expect.tex +1/−1
- test/m2m/equationNumberLaTeX/expect.tex +5/−5
- test/m2m/equations-auto/expect.tex +5/−5
- test/m2m/equations-tables-auto/expect.tex +5/−5
- test/m2m/equations-tables/expect.tex +5/−5
- test/m2m/equations/expect.tex +5/−5
- test/m2m/label-precedence/expect.tex +1/−1
- test/m2m/links-names/expect.tex +5/−5
- test/m2m/links/expect.tex +5/−5
- test/m2m/listOfOrdering/expect.md +33/−0
- test/m2m/listOfOrdering/expect.tex +42/−0
- test/m2m/listOfOrdering/input.md +25/−0
- test/m2m/listOfTemplates-buillet-list/expect.md +9/−9
- test/m2m/multiple-eqn-same-para/expect.tex +2/−2
- test/m2m/setLabelAttribute/expect.tex +1/−1
- test/test-pandoc-crossref.hs +11/−4
CHANGELOG.md view
@@ -1,3 +1,10 @@+## 0.3.18.2++- Ensure items in list-of are in order of appearance++ See [#466](https://github.com/lierdakil/pandoc-crossref/issues/466) for more+ info.+ ## 0.3.18.1 - Minor refactor to avoid new warnings introduced in GHC 9.8.
lib-internal/Text/Pandoc/CrossRef/References/Blocks/Header.hs view
@@ -66,9 +66,11 @@ | otherwise = S.replicate (n-ln-1) (0, Nothing) in cc' cc <- use $ ctrsAt PfxSec+ globCtr <- stGlob <<%= (+ 1) when ("sec:" `T.isPrefixOf` label') $ refsAt PfxSec %= M.insert label' RefRec { refIndex = cc+ , refGlobal = globCtr , refTitle = text' , refSubfigure = Nothing }
lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs view
@@ -49,7 +49,8 @@ runSubfigures (label, cls, attrs) images caption = do opts <- ask idxStr <- replaceAttr (Right label) attrs caption SPfxImg- let (cont, st) = flip runState def+ glob <- use stGlob+ let (cont, st) = flip runState (References def def glob) $ flip runReaderT opts' $ runWS $ runReplace (mkRR replaceSubfigs `extRR` doFigure) images@@ -82,6 +83,7 @@ let mangledSubfigures = mangleSubfigure <$> st ^. refsAt PfxImg mangleSubfigure v = v{refIndex = refIndex lastRef, refSubfigure = Just $ refIndex v} refsAt PfxImg %= (<> mangledSubfigures)+ stGlob .= st ^. stGlob if | isLatexFormat opts -> replaceNoRecurse $ Div nullAttr $ [ RawBlock (Format "latex") "\\begin{pandoccrossrefsubfigures}" ]
lib-internal/Text/Pandoc/CrossRef/References/Blocks/Util.hs view
@@ -95,9 +95,11 @@ label' = either (<> T.pack (':' : show index)) id label when (M.member label' prop') $ error . T.unpack $ "Duplicate label: " <> label'+ globCtr <- stGlob <<%= (+ 1) ctrsAt pfx .= index refsAt pfx %= M.insert label' RefRec { refIndex= index+ , refGlobal = globCtr , refTitle= title , refSubfigure = Nothing }
lib-internal/Text/Pandoc/CrossRef/References/List.hs view
@@ -77,9 +77,9 @@ mergeList _ _ _ = Nothing refsSorted = sortBy compare' $ M.toList refs compare'- (_,RefRec{refIndex=i, refSubfigure=si})- (_,RefRec{refIndex=j, refSubfigure=sj})- = compare (i, si) (j, sj)+ (_,RefRec{refGlobal=i})+ (_,RefRec{refGlobal=j})+ = compare i j itemChap :: Options -> RefRec -> [Block] itemChap o ref@RefRec{..} = applyTemplate (numWithChap o ref) refTitle (tf o) numWithChap :: Options -> RefRec -> [Inline]
lib-internal/Text/Pandoc/CrossRef/References/Types.hs view
@@ -22,6 +22,7 @@ module Text.Pandoc.CrossRef.References.Types where import Data.Default+import Numeric.Natural import qualified Data.Map as M import Data.Text (Text) import Lens.Micro.GHC@@ -32,6 +33,7 @@ type Index = S.Seq (Int, Maybe Text) data RefRec = RefRec { refIndex :: Index+ , refGlobal :: Natural , refTitle :: [Inline] , refSubfigure :: Maybe Index } deriving (Show, Eq)@@ -49,10 +51,11 @@ -- state data type data References = References { _stRefs :: M.Map Prefix RefMap , _stCtrs :: M.Map Prefix Index+ , _stGlob :: Natural } deriving (Show, Eq) instance Default References where- def = References mempty mempty+ def = References mempty mempty 0 makeLenses ''References
pandoc-crossref.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: pandoc-crossref-version: 0.3.18.1+version: 0.3.18.2 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@@ -75,6 +75,9 @@ test/m2m/listings-code-block-caption-278/expect.md test/m2m/listings-code-block-caption-278/expect.tex test/m2m/listings-code-block-caption-278/input.md+ test/m2m/listOfOrdering/expect.md+ test/m2m/listOfOrdering/expect.tex+ test/m2m/listOfOrdering/input.md test/m2m/listOfTemplates-buillet-list/expect.md test/m2m/listOfTemplates-buillet-list/expect.tex test/m2m/listOfTemplates-buillet-list/input.md
test/m2m/delim/expect.tex view
@@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/eqnBlockTemplate/expect.tex view
@@ -1,1 +1,1 @@-\begin{equation}\phantomsection\label{eq:1}{\int_0^x e^x dx}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{\int_0^x e^x dx}\end{equation}
test/m2m/eqnDisplayTemplate/expect.tex view
@@ -1,3 +1,3 @@-\begin{equation}\phantomsection\label{eq:euler}{e^{i\pi} = -1}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:euler}{e^{i\pi} = -1}\end{equation} eq.~\ref{eq:euler}
test/m2m/eqnInlineTableTemplate/expect.tex view
@@ -1,3 +1,3 @@-\begin{equation}\phantomsection\label{eq:euler}{e^{i\pi} = -1}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:euler}{e^{i\pi} = -1}\end{equation} eq.~\ref{eq:euler}
test/m2m/eqnInlineTemplate/expect.tex view
@@ -1,1 +1,1 @@-\begin{equation}\phantomsection\label{eq:1}{\int_0^x e^x dx}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{\int_0^x e^x dx}\end{equation}
test/m2m/equationNumberLaTeX/expect.tex view
@@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/equations-auto/expect.tex view
@@ -15,20 +15,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/equations-tables-auto/expect.tex view
@@ -15,20 +15,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/equations-tables/expect.tex view
@@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/equations/expect.tex view
@@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/label-precedence/expect.tex view
@@ -46,6 +46,6 @@ 4 & 5 & 6 \\ \end{longtable} -\begin{equation}\phantomsection\label{eq:equation}{y = e^x}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:equation}{y = e^x}\end{equation} fig.~\ref{fig:fig3} tbl.~\ref{tbl:table} eq.~\ref{eq:equation}
test/m2m/links-names/expect.tex view
@@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
test/m2m/links/expect.tex view
@@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line-\begin{equation}\phantomsection\label{eq:0}{ this }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:0}{ this }\end{equation} Some equations might be inside of text,-\begin{equation}\phantomsection\label{eq:1}{ for example }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -\begin{equation}\phantomsection\label{eq:2}{ start }\end{equation} of-paragraph.+\begin{equation}\protect\phantomsection\label{eq:2}{ start }\end{equation}+of paragraph. Other might be on separate paragraphs of their own: -\begin{equation}\phantomsection\label{eq:3}{ separate }\end{equation}+\begin{equation}\protect\phantomsection\label{eq:3}{ separate }\end{equation} Then they can be referenced:
+ test/m2m/listOfOrdering/expect.md view
@@ -0,0 +1,33 @@+# main section {#main-section .unnumbered}++blah blah blah figs. 1, S.1++{#fig:fig1}++furthermore, etc., (figs. S.2, 2)++{#fig:fig2}++and finally (fig. 3)++{#fig:fig3}++# supplemental section {#supplemental-section label="S"}++{#fig:fig_s1}++{#fig:fig_s2}++# List of Figures++::: {.list .list-of-fig}+1\. first figure\++2\. second figure\++3\. third figure\++S.1. first supp figure\++S.2. second supp figure\+:::
+ test/m2m/listOfOrdering/expect.tex view
@@ -0,0 +1,42 @@+\section*{main section}\label{main-section}+\addcontentsline{toc}{section}{main section}++blah blah blah figs.~\ref{fig:fig1}, \ref{fig:fig_s1}++\begin{figure}+\centering+\pandocbounded{\includegraphics[keepaspectratio]{figs/fig1.jpg}}+\caption{first figure}\label{fig:fig1}+\end{figure}++furthermore, etc., (figs.~\ref{fig:fig2}, \ref{fig:fig_s2})++\begin{figure}+\centering+\pandocbounded{\includegraphics[keepaspectratio]{figs/fig2.jpg}}+\caption{second figure}\label{fig:fig2}+\end{figure}++and finally (fig.~\ref{fig:fig3})++\begin{figure}+\centering+\pandocbounded{\includegraphics[keepaspectratio]{figs/fig3.jpg}}+\caption{third figure}\label{fig:fig3}+\end{figure}++\section{supplemental section}\label{supplemental-section}++\begin{figure}+\centering+\pandocbounded{\includegraphics[keepaspectratio]{figs/fig_s1.jpg}}+\caption{first supp figure}\label{fig:fig_s1}+\end{figure}++\begin{figure}+\centering+\pandocbounded{\includegraphics[keepaspectratio]{figs/fig_s2.jpg}}+\caption{second supp figure}\label{fig:fig_s2}+\end{figure}++\listoffigures
+ test/m2m/listOfOrdering/input.md view
@@ -0,0 +1,25 @@+---+chapters: true+---++# main section {-}++blah blah blah [@fig:fig1; @fig:fig_s1]++{#fig:fig1}++furthermore, etc., ([@fig:fig2; @fig:fig_s2])++{#fig:fig2}++and finally ([@fig:fig3])++{#fig:fig3}++# supplemental section {label="S"}++{#fig:fig_s1}++{#fig:fig_s2}++\listoffigures
test/m2m/listOfTemplates-buillet-list/expect.md view
@@ -19,13 +19,13 @@ # List of Figures ::: {.list .list-of-fig}-- 1: 1-- 2: 2-- 3: 3-- 4: 4-- 5: 5-- 6: 6-- 7: 7-- 8: 8-- 9: 9+- 1: 1+- 2: 2+- 3: 3+- 4: 4+- 5: 5+- 6: 6+- 7: 7+- 8: 8+- 9: 9 :::
test/m2m/multiple-eqn-same-para/expect.tex view
@@ -1,5 +1,5 @@ Simple test-\begin{equation}\phantomsection\label{eq:1}{x=y}\end{equation}-\begin{equation}\phantomsection\label{eq:2}{x=y}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{x=y}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:2}{x=y}\end{equation} eqns.~\ref{eq:1}, \ref{eq:2}
test/m2m/setLabelAttribute/expect.tex view
@@ -6,7 +6,7 @@ \caption{Figure}\label{fig:1} \end{figure} -\begin{equation}\phantomsection\label{eq:1}{equation}\end{equation}+\begin{equation}\protect\phantomsection\label{eq:1}{equation}\end{equation} \begin{longtable}[]{@{}ll@{}} \caption{\label{tbl:1}Table}\tabularnewline
test/test-pandoc-crossref.hs view
@@ -118,26 +118,32 @@ ) , PfxImg =: M.fromList [("fig:figure1",RefRec { refIndex = [(1,Nothing)],+ refGlobal = 1, refTitle = [Str "Test",Space,Str "figure",Space,Str "1"], refSubfigure = Just [(1, Just "a")]}), ("fig:figure2",RefRec { refIndex = [(1,Nothing)],+ refGlobal = 2, refTitle = [Str "Test",Space,Str "figure",Space,Str "2"], refSubfigure = Just [(2, Just "b")]}), ("fig:subfigure",RefRec { refIndex = [(1,Nothing)],+ refGlobal = 0, refTitle = [Str "figure",Space,Str "caption"], refSubfigure = Nothing}), ("fig:figure21",RefRec { refIndex = [(2,Nothing)],+ refGlobal = 4, refTitle = [Str "Test",Space,Str "figure",Space,Str "21"], refSubfigure = Just [(1, Just "a")]}), ("fig:figure22",RefRec { refIndex = [(2,Nothing)],+ refGlobal = 5, refTitle = [Str "Test",Space,Str "figure",Space,Str "22"], refSubfigure = Just [(2, Just "b")]}), ("fig:subfigure2",RefRec { refIndex = [(2,Nothing)],+ refGlobal = 3, refTitle = [Str "figure",Space,Str "caption",Space,Str "2"], refSubfigure = Nothing}) ]@@ -309,12 +315,12 @@ <> para (citeGen "fig:figure_label" [1]) `test` "\\begin{figure}\n\\centering\n\\pandocbounded{\\includegraphics[keepaspectratio]{img.png}}\n\\caption{Title}\\label{fig:figure_label1}\n\\end{figure}\n\nfig.~\\ref{fig:figure_label1}" +#ifdef FLAKY it "Eqn labels" $ equation "x^2" "some_equation1" <> para (citeGen "eq:some_equation" [1])- `test` "\\begin{equation}\\phantomsection\\label{eq:some_equation1}{x^2}\\end{equation}\n\neq.~\\ref{eq:some_equation1}"+ `test` "\\begin{equation}\\protect\\phantomsection\\label{eq:some_equation1}{x^2}\\end{equation}\n\neq.~\\ref{eq:some_equation1}" -#ifdef FLAKY it "Tbl labels" $ table' "A table" "some_table1" <> para (citeGen "tbl:some_table" [1])@@ -356,13 +362,13 @@ refGen' p l1 l2 = M.fromList $ mconcat $ zipWith refRec''' (((uncapitalizeFirst p<>) . T.pack . show) `map` l1) l2 refRec' :: T.Text -> Int -> T.Text -> [(T.Text, RefRec)]-refRec' ref i tit = [(ref, RefRec{refIndex=[(i,Nothing)],refTitle=toList $ text tit,refSubfigure=Nothing})]+refRec' ref i tit = [(ref, RefRec{refIndex=[(i,Nothing)],refGlobal=0,refTitle=toList $ text tit,refSubfigure=Nothing})] refRec'' :: T.Text -> Int -> [(T.Text, RefRec)] refRec'' ref i = refRec' ref i "" refRec''' :: T.Text -> (Int, Int) -> [(T.Text, RefRec)]-refRec''' ref (c,i) = [(ref, RefRec{refIndex=[(c,Nothing), (i,Nothing)],refTitle=toList $ text "",refSubfigure=Nothing})]+refRec''' ref (c,i) = [(ref, RefRec{refIndex=[(c,Nothing), (i,Nothing)],refGlobal=0,refTitle=toList $ text "",refSubfigure=Nothing})] testRefs' :: T.Text -> [Int] -> [Int] -> Prefix -> T.Text -> Expectation testRefs' p l1 l2 prop res = testRefs (para $ citeGen p l1) (set (refsAt prop) (refGen p l1 l2) def) (para $ text res)@@ -462,3 +468,4 @@ a =: b = def & ctrsAt a .~ (refIndex $ last $ M.elems b) & refsAt a .~ b+ & stGlob %~ (+ fromIntegral (M.size b))