pandoc-crossref 0.3.13.0 → 0.3.14.0
raw patch · 28 files changed
+1345/−93 lines, 28 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +28/−0
- docs/demo/demo.md +2/−0
- docs/index.md +50/−7
- lib-internal/Text/Pandoc/CrossRef/References/List.hs +55/−18
- lib-internal/Text/Pandoc/CrossRef/Util/ModifyMeta.hs +4/−2
- lib-internal/Text/Pandoc/CrossRef/Util/Options.hs +3/−0
- lib-internal/Text/Pandoc/CrossRef/Util/Settings.hs +7/−0
- lib-internal/Text/Pandoc/CrossRef/Util/Settings/Gen.hs +4/−0
- lib-internal/Text/Pandoc/CrossRef/Util/Template.hs +1/−1
- pandoc-crossref.cabal +31/−18
- test/demo-chapters.inc +77/−26
- test/demo.inc +101/−19
- test/m2m/eqnInlineTemplate/expect.md +1/−0
- test/m2m/eqnInlineTemplate/expect.tex +1/−0
- test/m2m/eqnInlineTemplate/input.md +8/−0
- test/m2m/listOfTemplates-buillet-list/expect.md +31/−0
- test/m2m/listOfTemplates-buillet-list/expect.tex +73/−0
- test/m2m/listOfTemplates-buillet-list/input.md +25/−0
- test/m2m/listOfTemplates-ord-list/expect.md +31/−0
- test/m2m/listOfTemplates-ord-list/expect.tex +73/−0
- test/m2m/listOfTemplates-ord-list/input.md +25/−0
- test/m2m/listOfTemplates/expect.md +114/−0
- test/m2m/listOfTemplates/expect.tex +170/−0
- test/m2m/listOfTemplates/input.md +71/−0
- test/m2m/loxItemTitle/expect.md +114/−0
- test/m2m/loxItemTitle/expect.tex +170/−0
- test/m2m/loxItemTitle/input.md +71/−0
- test/test-pandoc-crossref.hs +4/−2
CHANGELOG.md view
@@ -1,3 +1,31 @@+## 0.3.14.0++### Main changes++- Add list-of-x item templates++ New template variables, `lofItemTemplate`, `lotItemTemplate`,+ `lolItemTemplate`, allowing to specify formatting for elements in lists-of+ items.++ Default values for templates also use variables `lofItemTitle`,+ `lotItemTitle`, `lolItemTitle`, `listItemTitleDelim`.++ Historically, list-of-x lists were formatted using markdown ordered lists when not using `chapters: true`. However, this is not enabled by default any more. You can restore the old behaviour by specifying the template using ordered list explicitly, e.g.++ ```yaml+ lofItemTemplate: |+ 1. $$t$$+ ```++ Note that custom numbering (including chapter numbers) will be ignored by ordered lists, so it only works well for the simplest numbering schemes.++ Bullet lists are also now supported.++- Fix cleveref latex preamble++ Cleveref now complains if it's loaded before hyperref, hence loading cleveref was wrapped into `AtEndPreamble`.+ ## 0.3.13.0 ### Main changes
docs/demo/demo.md view
@@ -6,6 +6,8 @@ ## List of Figures lotTitle: | ## List of Tables+lolTitle: |+ ## List of Listings tableTemplate: | *$$tableTitle$$ $$i$$*$$titleDelim$$ $$t$$ autoSectionLabels: True
docs/index.md view
@@ -437,15 +437,15 @@ ## Lists It's possible to use raw latex commands `\listoffigures`,-`\listoftables` and `listoflistings`, which will produce ordered list of+`\listoftables` and `\listoflistings`, which will produce ordered list of figure/table/listings titles, in order of appearance in document. -`\listoflistings` depends on other options, and is defined in preamble,-so it will work reliably only with standalone/pdf output.+For LaTeX output, `\listoflistings` depends on other options, and is defined in+preamble, so it will work reliably only with standalone/pdf output. -**NOTE:** With Pandoc 2.0.6 and up, you'll have to explicitly separate+**NOTE:** With Pandoc 2.0.6 and up, you might have to explicitly separate these commands if they are close together, at least when targeting-something besides LaTeX. So this will not work:+something besides LaTeX. So this might not work: ``` markdown \listoffigures@@ -459,12 +459,18 @@ ``` markdown \listoffigures-[]: hack to split raw blocks++<!-- hack to split raw blocks -->+ \listoftables-[]: hack to split raw blocks++<!-- hack to split raw blocks -->+ \listoflistings ``` +With HTML-compatible output, lists are wrapped into a `div` with classes `list` and `list-of-<prefix>`, where `<prefix>` is either `fig`, `tbl` or `lst` depending on the type of the list. This allows for ad-hoc style overrides in HTML.+ # Usage Run pandoc with `--filter` option, passing path to pandoc-crossref@@ -559,6 +565,15 @@ - `lolTitle`, default `# List of Listings`: Title for list of listings (lol) +### List items++See also [List item templates](#list-item-templates)++- `lofItemTitle`, default empty: Title each item in the list of figures, i.e. each item will be prefixed by this string.+- `lotItemTitle`, default empty: Title each item in the list of tables, i.e. each item will be prefixed by this string.+- `lolItemTitle`, default empty: Title each item in the list of listings, i.e. each item will be prefixed by this string.+- `listItemTitleDelim`, default `.` (str "."): delimiter between list item numbers and captions.+ ### Reference format - `figPrefix`, default `fig.`, `figs.`: Prefix for references to@@ -726,6 +741,34 @@ index template - `subfigureRefIndexTemplate`, default `$$i$$$$suf$$ ($$s$$)` -- subfigure reference index template++### List item templates++See [Templates](#templates)++- `lofItemTemplate`, default `$$lofItemTitle$$$$i$$$$listItemTitleDelim$$ $$t$$\\\n` -- list-of-figures item template+- `lotItemTemplate`, default `$$lotItemTitle$$$$i$$$$listItemTitleDelim$$ $$t$$\\\n`)+- `lolItemTemplate`, default `$$lolItemTitle$$$$i$$$$listItemTitleDelim$$ $$t$$\\\n`)++Special handling is enabled for templates that are either ordered or bullet lists: items will be merged into a single list. Thus, for example, given++```yaml+lofItemTemplate: |+ 1. $$t$$+```++the list of figures will be formatted as++```markdown+# List of Figures++::: {.list .list-of-fig}+1. Figure 1 caption+2. Figure 2 caption+3. Figure 3 caption+4. ...+:::+``` ### LaTeX customization
lib-internal/Text/Pandoc/CrossRef/References/List.hs view
@@ -18,45 +18,82 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -} -{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, RecordWildCards #-} module Text.Pandoc.CrossRef.References.List (listOf) where -import Control.Arrow import Data.List import qualified Data.Map as M import qualified Data.Text as T import Text.Pandoc.Definition+import Data.Maybe import Lens.Micro.Mtl import Text.Pandoc.CrossRef.References.Types import Text.Pandoc.CrossRef.Util.Options import Text.Pandoc.CrossRef.Util.Util+import Text.Pandoc.CrossRef.Util.Template listOf :: Options -> [Block] -> WS [Block] listOf Options{outFormat=f} x | isLatexFormat f = return x listOf opts (RawBlock fmt "\\listoffigures":xs) | isLaTeXRawBlockFmt fmt- = use imgRefs >>= makeList opts lofTitle xs+ = use imgRefs >>= makeList "fig" opts lofItemTemplate lofTitle xs listOf opts (RawBlock fmt "\\listoftables":xs) | isLaTeXRawBlockFmt fmt- = use tblRefs >>= makeList opts lotTitle xs+ = use tblRefs >>= makeList "tbl" opts lotItemTemplate lotTitle xs listOf opts (RawBlock fmt "\\listoflistings":xs) | isLaTeXRawBlockFmt fmt- = use lstRefs >>= makeList opts lolTitle xs+ = use lstRefs >>= makeList "lst" opts lolItemTemplate lolTitle xs listOf _ x = return x -makeList :: Options -> (Options -> [Block]) -> [Block] -> M.Map T.Text RefRec -> WS [Block]-makeList opts titlef xs refs- = return $- titlef opts ++- (if chaptersDepth opts > 0- then Div ("", ["list"], []) (itemChap `map` refsSorted)- else OrderedList style (item `map` refsSorted))- : xs+makeList+ :: T.Text+ -> Options+ -> (Options+ -> BlockTemplate)+ -> (Options+ -> [Block])+ -> [Block]+ -> M.Map T.Text RefRec+ -> WS [Block]+makeList pfx o tf titlef xs refs =+ pure $ titlef o <> (Div ("", ["list", "list-of-" <> pfx], []) items : xs) where+ items = fromMaybe items'$ pure <$> mergeList Nothing [] items'+ items' = concatMap (itemChap . snd) refsSorted+ mergeList Nothing acc (OrderedList style item : ys) =+ mergeList (Just $ OrderedList style) (item <> acc) ys+ mergeList Nothing acc (BulletList item : ys) =+ mergeList (Just BulletList) (item <> acc) ys+ mergeList (Just cons) acc (OrderedList style item : ys)+ | cons [] == OrderedList style [] =+ mergeList (Just $ OrderedList style) (item <> acc) ys+ mergeList (Just cons) acc (BulletList item : ys)+ | cons [] == BulletList[] =+ mergeList (Just BulletList) (item <> acc) ys+ mergeList (Just cons) acc [] = Just $ cons $ reverse acc+ mergeList _ _ _ = Nothing refsSorted = sortBy compare' $ M.toList refs- compare' (_,RefRec{refIndex=i}) (_,RefRec{refIndex=j}) = compare i j- item = (:[]) . Plain . refTitle . snd- itemChap = Para . uncurry ((. (Space :)) . (++)) . (numWithChap . refIndex &&& refTitle) . snd- numWithChap = chapPrefix (chapDelim opts)- style = (1,DefaultStyle,DefaultDelim)+ compare'+ (_,RefRec{refIndex=i, refSubfigure=si})+ (_,RefRec{refIndex=j, refSubfigure=sj})+ = compare (i, si) (j, sj)+ itemChap :: RefRec -> [Block]+ itemChap ref@RefRec{..} = applyTemplate (numWithChap ref) refTitle (tf o)+ numWithChap :: RefRec -> [Inline]+ numWithChap RefRec{..} = case refSubfigure of+ Nothing ->+ let vars = M.fromDistinctAscList+ [ ("i", chapPrefix (chapDelim o) refIndex)+ , ("suf", mempty)+ , ("t", refTitle)+ ]+ in applyTemplate' vars $ refIndexTemplate o pfx+ Just s ->+ let vars = M.fromDistinctAscList+ [ ("i", chapPrefix (chapDelim o) refIndex)+ , ("s", chapPrefix (chapDelim o) s)+ , ("suf", mempty)+ , ("t", refTitle)+ ]+ in applyTemplate' vars $ subfigureRefIndexTemplate o
lib-internal/Text/Pandoc/CrossRef/Util/ModifyMeta.hs view
@@ -53,12 +53,13 @@ unless (listings opts) $ tell codelisting tell lolcommand- when (cref opts) $ do+ when (cref opts) $ atEndPreamble $ do tell cleveref unless (listings opts) $ tell cleverefCodelisting tell [ "\\makeatother" ] where+ atEndPreamble = censor (\c -> "\\AtEndPreamble{%":c <> ["}"]) subfig = [ usepackage [] "subfig" , usepackage [] "caption"@@ -108,7 +109,8 @@ , "}" ] | otherwise = ["\\newcommand*\\listoflistings{\\listof{codelisting}{" <> metaString' "lolTitle" <> "}}"]- cleveref = [ usepackage cleverefOpts "cleveref" ]+ cleveref =+ [ usepackage cleverefOpts "cleveref" ] <> crefname "figure" figPrefix <> crefname "table" tblPrefix <> crefname "equation" eqnPrefix
lib-internal/Text/Pandoc/CrossRef/Util/Options.hs view
@@ -40,6 +40,9 @@ , tblPrefixTemplate :: Template , lstPrefixTemplate :: Template , secPrefixTemplate :: Template+ , lofItemTemplate :: BlockTemplate+ , lotItemTemplate :: BlockTemplate+ , lolItemTemplate :: BlockTemplate , eqnBlockTemplate :: BlockTemplate , eqnBlockInlineMath :: Bool , eqnIndexTemplate :: Template
lib-internal/Text/Pandoc/CrossRef/Util/Settings.hs view
@@ -115,6 +115,13 @@ <> figureTemplate (var "figureTitle" <> space <> var "i" <> var "titleDelim" <> space <> var "t") <> tableTemplate (var "tableTitle" <> space <> var "i" <> var "titleDelim" <> space <> var "t") <> listingTemplate (var "listingTitle" <> space <> var "i" <> var "titleDelim" <> space <> var "t")+ <> lofItemTemplate (plain $ var "lofItemTitle" <> var "i" <> var "listItemTitleDelim" <> space <> var "t" <> linebreak)+ <> lotItemTemplate (plain $ var "lotItemTitle" <> var "i" <> var "listItemTitleDelim" <> space <> var "t" <> linebreak)+ <> lolItemTemplate (plain $ var "lolItemTitle" <> var "i" <> var "listItemTitleDelim" <> space <> var "t" <> linebreak)+ <> lofItemTitle (mempty :: Inlines)+ <> lotItemTitle (mempty :: Inlines)+ <> lolItemTitle (mempty :: Inlines)+ <> listItemTitleDelim (str ".") <> crossrefYaml (MetaString "pandoc-crossref.yaml") <> subfigureChildTemplate (var "i") <> subfigureTemplate (var "figureTitle" <> space <> var "i" <> var "titleDelim" <> space <> var "t" <> str "." <> space <> var "ccs")
lib-internal/Text/Pandoc/CrossRef/Util/Settings/Gen.hs view
@@ -44,6 +44,10 @@ , "lstLabels" , "secLabels" , "secHeaderDelim"+ , "listItemTitleDelim"+ , "lofItemTitle"+ , "lotItemTitle"+ , "lolItemTitle" ] getOptions :: Meta -> Maybe Format -> Options
lib-internal/Text/Pandoc/CrossRef/Util/Template.hs view
@@ -85,6 +85,6 @@ internalVars :: M.Map T.Text [Inline] -> T.Text -> Maybe MetaValue internalVars vars x = MetaInlines <$> M.lookup x vars -applyTemplate :: MkTemplate a b =>[Inline] -> [Inline] -> b -> [a]+applyTemplate :: MkTemplate a b => [Inline] -> [Inline] -> b -> [a] applyTemplate i t = applyTemplate' (M.fromDistinctAscList [("i", i), ("t", t)])
pandoc-crossref.cabal view
@@ -3,11 +3,9 @@ -- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: 284171f1ac9b309f9076827741d8057c87cc91d18ea79b096192c8f9345ae485 name: pandoc-crossref-version: 0.3.13.0+version: 0.3.14.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@@ -38,6 +36,9 @@ test/m2m/eqnBlockTemplate/expect.md test/m2m/eqnBlockTemplate/expect.tex test/m2m/eqnBlockTemplate/input.md+ test/m2m/eqnInlineTemplate/expect.md+ test/m2m/eqnInlineTemplate/expect.tex+ test/m2m/eqnInlineTemplate/input.md test/m2m/equationNumberLaTeX/expect.md test/m2m/equationNumberLaTeX/expect.tex test/m2m/equationNumberLaTeX/input.md@@ -68,6 +69,18 @@ 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/listOfTemplates-buillet-list/expect.md+ test/m2m/listOfTemplates-buillet-list/expect.tex+ test/m2m/listOfTemplates-buillet-list/input.md+ test/m2m/listOfTemplates-ord-list/expect.md+ test/m2m/listOfTemplates-ord-list/expect.tex+ test/m2m/listOfTemplates-ord-list/input.md+ test/m2m/listOfTemplates/expect.md+ test/m2m/listOfTemplates/expect.tex+ test/m2m/listOfTemplates/input.md+ test/m2m/loxItemTitle/expect.md+ test/m2m/loxItemTitle/expect.tex+ test/m2m/loxItemTitle/input.md test/m2m/multiple-eqn-same-para/expect.md test/m2m/multiple-eqn-same-para/expect.tex test/m2m/multiple-eqn-same-para/input.md@@ -113,11 +126,11 @@ ghc-options: -Wall build-depends: base >=4.11 && <5- , mtl >=1.1 && <2.3- , pandoc ==2.18.*+ , mtl >=1.1 && <2.4+ , pandoc >=2.18 && <2.20 , pandoc-crossref-internal , pandoc-types >=1.22.2 && <1.23- , text >=1.2.2 && <1.3+ , text >=1.2.2 && <2.1 default-language: Haskell2010 library pandoc-crossref-internal@@ -150,11 +163,11 @@ , 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.18.*+ , pandoc >=2.18 && <2.20 , pandoc-types >=1.22.2 && <1.23 , syb >=0.4 && <0.8 , template-haskell >=2.7.0.0 && <3.0.0.0- , text >=1.2.2 && <1.3+ , text >=1.2.2 && <2.1 , utility-ht >=0.0.11 && <0.1.0 default-language: Haskell2010 @@ -170,13 +183,13 @@ , deepseq ==1.4.* , gitrev >=1.3.1 && <1.4 , open-browser ==0.2.*- , optparse-applicative >=0.13 && <0.17- , pandoc ==2.18.*+ , optparse-applicative >=0.13 && <0.18+ , pandoc >=2.18 && <2.20 , pandoc-crossref , pandoc-types >=1.22.2 && <1.23 , template-haskell >=2.7.0.0 && <3.0.0.0 , temporary >=1.2 && <1.4- , text >=1.2.2 && <1.3+ , text >=1.2.2 && <2.1 default-language: Haskell2010 test-suite test-integrative@@ -190,10 +203,10 @@ , directory >=1 && <1.4 , filepath >=1.1 && <1.5 , hspec >=2.4.4 && <3- , pandoc ==2.18.*+ , pandoc >=2.18 && <2.20 , pandoc-crossref , pandoc-types >=1.22.2 && <1.23- , text >=1.2.2 && <1.3+ , text >=1.2.2 && <2.1 if flag(enable_flaky_tests) cpp-options: -DFLAKY default-language: Haskell2010@@ -216,11 +229,11 @@ , hspec >=2.4.4 && <3 , microlens >=0.4.12.0 && <0.5.0.0 , mtl >=1.1 && <2.3- , pandoc ==2.18.*+ , pandoc >=2.18 && <2.20 , pandoc-crossref , pandoc-crossref-internal , pandoc-types >=1.22.2 && <1.23- , text >=1.2.2 && <1.3+ , text >=1.2.2 && <2.1 if flag(enable_flaky_tests) cpp-options: -DFLAKY default-language: Haskell2010@@ -235,9 +248,9 @@ ghc-options: -Wall -fno-warn-unused-do-bind -threaded build-depends: base >=4.11 && <5- , criterion >=1.5.9.0 && <1.6- , pandoc ==2.18.*+ , criterion >=1.5.9.0 && <1.7+ , pandoc >=2.18 && <2.20 , pandoc-crossref , pandoc-types >=1.22.2 && <1.23- , text >=1.2.2 && <1.3+ , text >=1.2.2 && <2.1 default-language: Haskell2010
test/demo-chapters.inc view
@@ -965,61 +965,112 @@ ( "list-of-figures" , [] , [] ) [ Str "List" , Space , Str "of" , Space , Str "Figures" ] , Div- ( "" , [ "list" ] , [] )- [ Para [ Str "1" , Space , Str "A" , Space , Str "figure" ]- , Para- [ Str "1.1" , Space , Str "First" , Space , Str "figure" ]- , Para- [ Str "1.2" , Space , Str "Second" , Space , Str "figure" ]- , Para- [ Str "1.3" , Space , Str "Third" , Space , Str "figure" ]- , Para- [ Str "1.4" , Space , Str "Subfigure" , Space , Str "a" ]- , Para- [ Str "1.4" , Space , Str "Subfigure" , Space , Str "b" ]- , Para- [ Str "1.4"+ ( "" , [ "list" , "list-of-fig" ] , [] )+ [ Plain+ [ Str "1." , Space+ , Str "A"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "1.1."+ , Space+ , Str "First"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "1.2."+ , Space+ , Str "Second"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "1.3."+ , Space+ , Str "Third"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "1.4."+ , Space , Str "Subfigures" , Space , Str "caption"+ , LineBreak ]+ , Plain+ [ Str "1.4"+ , Space+ , Str "(a)."+ , Space+ , Str "Subfigure"+ , Space+ , Str "a"+ , LineBreak+ ]+ , Plain+ [ Str "1.4"+ , Space+ , Str "(b)."+ , Space+ , Str "Subfigure"+ , Space+ , Str "b"+ , LineBreak+ ] ] , Header 2 ( "list-of-tables" , [] , [] ) [ Str "List" , Space , Str "of" , Space , Str "Tables" ] , Div- ( "" , [ "list" ] , [] )- [ Para- [ Str "3.1" , Space , Str "Table" , Space , Str "example" ]+ ( "" , [ "list" , "list-of-tbl" ] , [] )+ [ Plain+ [ Str "3.1."+ , Space+ , Str "Table"+ , Space+ , Str "example"+ , LineBreak+ ] ] , Header- 1- ( "" , [] , [] )+ 2+ ( "list-of-listings" , [] , [] ) [ Str "List" , Space , Str "of" , Space , Str "Listings" ] , Div- ( "" , [ "list" ] , [] )- [ Para- [ Str "4.1"+ ( "" , [ "list" , "list-of-lst" ] , [] )+ [ Plain+ [ Str "4.1." , Space , Str "Listing" , Space , Str "caption"+ , LineBreak ]- , Para- [ Str "4.2"+ , Plain+ [ Str "4.2." , Space , Str "Listing" , Space , Str "caption"+ , LineBreak ]- , Para- [ Str "4.3"+ , Plain+ [ Str "4.3." , Space , Str "Listing" , Space , Str "caption"+ , LineBreak ] ] , Header
test/demo.inc view
@@ -963,32 +963,114 @@ 2 ( "list-of-figures" , [] , [] ) [ Str "List" , Space , Str "of" , Space , Str "Figures" ]- , OrderedList- ( 1 , DefaultStyle , DefaultDelim )- [ [ Plain [ Str "A" , Space , Str "figure" ] ]- , [ Plain [ Str "First" , Space , Str "figure" ] ]- , [ Plain [ Str "Second" , Space , Str "figure" ] ]- , [ Plain [ Str "Third" , Space , Str "figure" ] ]- , [ Plain [ Str "Subfigure" , Space , Str "a" ] ]- , [ Plain [ Str "Subfigure" , Space , Str "b" ] ]- , [ Plain [ Str "Subfigures" , Space , Str "caption" ] ]+ , Div+ ( "" , [ "list" , "list-of-fig" ] , [] )+ [ Plain+ [ Str "1."+ , Space+ , Str "A"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "2."+ , Space+ , Str "First"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "3."+ , Space+ , Str "Second"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "4."+ , Space+ , Str "Third"+ , Space+ , Str "figure"+ , LineBreak+ ]+ , Plain+ [ Str "5."+ , Space+ , Str "Subfigures"+ , Space+ , Str "caption"+ , LineBreak+ ]+ , Plain+ [ Str "5"+ , Space+ , Str "(a)."+ , Space+ , Str "Subfigure"+ , Space+ , Str "a"+ , LineBreak+ ]+ , Plain+ [ Str "5"+ , Space+ , Str "(b)."+ , Space+ , Str "Subfigure"+ , Space+ , Str "b"+ , LineBreak+ ] ] , Header 2 ( "list-of-tables" , [] , [] ) [ Str "List" , Space , Str "of" , Space , Str "Tables" ]- , OrderedList- ( 1 , DefaultStyle , DefaultDelim )- [ [ Plain [ Str "Table" , Space , Str "example" ] ] ]+ , Div+ ( "" , [ "list" , "list-of-tbl" ] , [] )+ [ Plain+ [ Str "1."+ , Space+ , Str "Table"+ , Space+ , Str "example"+ , LineBreak+ ]+ ] , Header- 1- ( "" , [] , [] )+ 2+ ( "list-of-listings" , [] , [] ) [ Str "List" , Space , Str "of" , Space , Str "Listings" ]- , OrderedList- ( 1 , DefaultStyle , DefaultDelim )- [ [ Plain [ Str "Listing" , Space , Str "caption" ] ]- , [ Plain [ Str "Listing" , Space , Str "caption" ] ]- , [ Plain [ Str "Listing" , Space , Str "caption" ] ]+ , Div+ ( "" , [ "list" , "list-of-lst" ] , [] )+ [ Plain+ [ Str "1."+ , Space+ , Str "Listing"+ , Space+ , Str "caption"+ , LineBreak+ ]+ , Plain+ [ Str "2."+ , Space+ , Str "Listing"+ , Space+ , Str "caption"+ , LineBreak+ ]+ , Plain+ [ Str "3."+ , Space+ , Str "Listing"+ , Space+ , Str "caption"+ , LineBreak+ ] ] , Header 1
+ test/m2m/eqnInlineTemplate/expect.md view
@@ -0,0 +1,1 @@+[$$\begin{array}{lr} \int_0^x e^x dx & (1) \end{array}$$]{#eq:1}
+ test/m2m/eqnInlineTemplate/expect.tex view
@@ -0,0 +1,1 @@+\begin{equation}\protect\hypertarget{eq:1}{}{\int_0^x e^x dx}\label{eq:1}\end{equation}
+ test/m2m/eqnInlineTemplate/input.md view
@@ -0,0 +1,8 @@+---+eqnInlineTemplate: |+ \\begin{array}{lr}+ $$e$$ & $$i$$+ \\end{array}+---++$$\int_0^x e^x dx$${#eq:1}
+ test/m2m/listOfTemplates-buillet-list/expect.md view
@@ -0,0 +1,31 @@+{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}++# 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+:::
+ test/m2m/listOfTemplates-buillet-list/expect.tex view
@@ -0,0 +1,73 @@+\begin{figure}+\hypertarget{fig:1}{%+\centering+\includegraphics{fig1.png}+\caption{1}\label{fig:1}+}+\end{figure}++\begin{figure}+\hypertarget{fig:2}{%+\centering+\includegraphics{fig2.png}+\caption{2}\label{fig:2}+}+\end{figure}++\begin{figure}+\hypertarget{fig:3}{%+\centering+\includegraphics{fig3.png}+\caption{3}\label{fig:3}+}+\end{figure}++\begin{figure}+\hypertarget{fig:4}{%+\centering+\includegraphics{fig4.png}+\caption{4}\label{fig:4}+}+\end{figure}++\begin{figure}+\hypertarget{fig:5}{%+\centering+\includegraphics{fig5.png}+\caption{5}\label{fig:5}+}+\end{figure}++\begin{figure}+\hypertarget{fig:6}{%+\centering+\includegraphics{fig6.png}+\caption{6}\label{fig:6}+}+\end{figure}++\begin{figure}+\hypertarget{fig:7}{%+\centering+\includegraphics{fig7.png}+\caption{7}\label{fig:7}+}+\end{figure}++\begin{figure}+\hypertarget{fig:8}{%+\centering+\includegraphics{fig8.png}+\caption{8}\label{fig:8}+}+\end{figure}++\begin{figure}+\hypertarget{fig:9}{%+\centering+\includegraphics{fig9.png}+\caption{9}\label{fig:9}+}+\end{figure}++\listoffigures
+ test/m2m/listOfTemplates-buillet-list/input.md view
@@ -0,0 +1,25 @@+---+lofItemTemplate: |+ - $$i$$: $$t$$+---++{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}+++\listoffigures
+ test/m2m/listOfTemplates-ord-list/expect.md view
@@ -0,0 +1,31 @@+{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}++# 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+:::
+ test/m2m/listOfTemplates-ord-list/expect.tex view
@@ -0,0 +1,73 @@+\begin{figure}+\hypertarget{fig:1}{%+\centering+\includegraphics{fig1.png}+\caption{1}\label{fig:1}+}+\end{figure}++\begin{figure}+\hypertarget{fig:2}{%+\centering+\includegraphics{fig2.png}+\caption{2}\label{fig:2}+}+\end{figure}++\begin{figure}+\hypertarget{fig:3}{%+\centering+\includegraphics{fig3.png}+\caption{3}\label{fig:3}+}+\end{figure}++\begin{figure}+\hypertarget{fig:4}{%+\centering+\includegraphics{fig4.png}+\caption{4}\label{fig:4}+}+\end{figure}++\begin{figure}+\hypertarget{fig:5}{%+\centering+\includegraphics{fig5.png}+\caption{5}\label{fig:5}+}+\end{figure}++\begin{figure}+\hypertarget{fig:6}{%+\centering+\includegraphics{fig6.png}+\caption{6}\label{fig:6}+}+\end{figure}++\begin{figure}+\hypertarget{fig:7}{%+\centering+\includegraphics{fig7.png}+\caption{7}\label{fig:7}+}+\end{figure}++\begin{figure}+\hypertarget{fig:8}{%+\centering+\includegraphics{fig8.png}+\caption{8}\label{fig:8}+}+\end{figure}++\begin{figure}+\hypertarget{fig:9}{%+\centering+\includegraphics{fig9.png}+\caption{9}\label{fig:9}+}+\end{figure}++\listoffigures
+ test/m2m/listOfTemplates-ord-list/input.md view
@@ -0,0 +1,25 @@+---+lofItemTemplate: |+ 1. $$t$$+---++{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}+++\listoffigures
+ test/m2m/listOfTemplates/expect.md view
@@ -0,0 +1,114 @@+{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}++::: {#lst:code1 .listing .haskell}+Listing 1: Listing caption 1++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++::: {#lst:code2 .listing .haskell}+Listing 2: Listing caption 2++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++::: {#lst:code3 .listing .haskell}+Listing 3: Listing caption 3++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++::: {#lst:code4 .listing .haskell}+Listing 4: Listing caption 4++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++------------------------------------------------------------------------++::: {#tbl:mytable}+ a b c+ --- --- ---+ 1 2 3+ 4 5 6++ : Table 1: My table+:::++::: {#tbl:1}+ a b+ --- ---+ 1 2++ : Table 2: Table+:::++# List of Figures++::: {.list .list-of-fig}+Figure 1. 1++Figure 2. 2++Figure 3. 3++Figure 4. 4++Figure 5. 5++Figure 6. 6++Figure 7. 7++Figure 8. 8++Figure 9. 9+:::++# List of Tables++::: {.list .list-of-tbl}+Title 1. My table++Title 2. Table+:::++# List of Listings++::: {.list .list-of-lst}+Listing 1. Listing caption 1++Listing 2. Listing caption 2++Listing 3. Listing caption 3++Listing 4. Listing caption 4+:::
+ test/m2m/listOfTemplates/expect.tex view
@@ -0,0 +1,170 @@+\begin{figure}+\hypertarget{fig:1}{%+\centering+\includegraphics{fig1.png}+\caption{1}\label{fig:1}+}+\end{figure}++\begin{figure}+\hypertarget{fig:2}{%+\centering+\includegraphics{fig2.png}+\caption{2}\label{fig:2}+}+\end{figure}++\begin{figure}+\hypertarget{fig:3}{%+\centering+\includegraphics{fig3.png}+\caption{3}\label{fig:3}+}+\end{figure}++\begin{figure}+\hypertarget{fig:4}{%+\centering+\includegraphics{fig4.png}+\caption{4}\label{fig:4}+}+\end{figure}++\begin{figure}+\hypertarget{fig:5}{%+\centering+\includegraphics{fig5.png}+\caption{5}\label{fig:5}+}+\end{figure}++\begin{figure}+\hypertarget{fig:6}{%+\centering+\includegraphics{fig6.png}+\caption{6}\label{fig:6}+}+\end{figure}++\begin{figure}+\hypertarget{fig:7}{%+\centering+\includegraphics{fig7.png}+\caption{7}\label{fig:7}+}+\end{figure}++\begin{figure}+\hypertarget{fig:8}{%+\centering+\includegraphics{fig8.png}+\caption{8}\label{fig:8}+}+\end{figure}++\begin{figure}+\hypertarget{fig:9}{%+\centering+\includegraphics{fig9.png}+\caption{9}\label{fig:9}+}+\end{figure}++\begin{codelisting}++\caption{Listing caption 1}++\hypertarget{lst:code1}{%+\label{lst:code1}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{codelisting}++\caption{Listing caption 2}++\hypertarget{lst:code2}{%+\label{lst:code2}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{codelisting}++\caption{Listing caption 3}++\hypertarget{lst:code3}{%+\label{lst:code3}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{codelisting}++\caption{Listing caption 4}++\hypertarget{lst:code4}{%+\label{lst:code4}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}++\hypertarget{tbl:mytable}{}+\begin{longtable}[]{@{}lll@{}}+\caption{\label{tbl:mytable}My table}\tabularnewline+\toprule()+a & b & c \\+\midrule()+\endfirsthead+\toprule()+a & b & c \\+\midrule()+\endhead+1 & 2 & 3 \\+4 & 5 & 6 \\+\bottomrule()+\end{longtable}++\hypertarget{tbl:1}{}+\begin{longtable}[]{@{}ll@{}}+\caption{\label{tbl:1}Table}\tabularnewline+\toprule()+a & b \\+\midrule()+\endfirsthead+\toprule()+a & b \\+\midrule()+\endhead+1 & 2 \\+\bottomrule()+\end{longtable}++\listoffigures++\listoftables++\listoflistings
+ test/m2m/listOfTemplates/input.md view
@@ -0,0 +1,71 @@+---+lofItemTemplate: "Figure $$i$$. $$t$$"+lotItemTemplate: "Title $$i$$. $$t$$"+lolItemTemplate: "Listing $$i$$. $$t$$"+codeBlockCaptions: true+---++{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}++```haskell+main :: IO ()+main = putStrLn "Hello World!"+```+: Listing caption 1 {#lst:code1}++```haskell+main :: IO ()+main = putStrLn "Hello World!"+```++: Listing caption 2 {#lst:code2}++```{#lst:code3 .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```+: Listing caption 3++```{#lst:code4 .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```++: Listing caption 4++***++a b c+--- --- ---+1 2 3+4 5 6++: My table {#tbl:mytable}++| a | b |+|---|---|+| 1 | 2 |++: Table {#tbl:1}++\listoffigures++\listoftables++\listoflistings
+ test/m2m/loxItemTitle/expect.md view
@@ -0,0 +1,114 @@+{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}++::: {#lst:code1 .listing .haskell}+Listing 1: Listing caption 1++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++::: {#lst:code2 .listing .haskell}+Listing 2: Listing caption 2++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++::: {#lst:code3 .listing .haskell}+Listing 3: Listing caption 3++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++::: {#lst:code4 .listing .haskell}+Listing 4: Listing caption 4++``` haskell+main :: IO ()+main = putStrLn "Hello World!"+```+:::++------------------------------------------------------------------------++::: {#tbl:mytable}+ a b c+ --- --- ---+ 1 2 3+ 4 5 6++ : Table 1: My table+:::++::: {#tbl:1}+ a b+ --- ---+ 1 2++ : Table 2: Table+:::++# List of Figures++::: {.list .list-of-fig}+Figure 1. 1\++Figure 2. 2\++Figure 3. 3\++Figure 4. 4\++Figure 5. 5\++Figure 6. 6\++Figure 7. 7\++Figure 8. 8\++Figure 9. 9\+:::++# List of Tables++::: {.list .list-of-tbl}+Title 1. My table\++Title 2. Table\+:::++# List of Listings++::: {.list .list-of-lst}+Listing 1: Listing caption 1\++Listing 2: Listing caption 2\++Listing 3: Listing caption 3\++Listing 4: Listing caption 4\+:::
+ test/m2m/loxItemTitle/expect.tex view
@@ -0,0 +1,170 @@+\begin{figure}+\hypertarget{fig:1}{%+\centering+\includegraphics{fig1.png}+\caption{1}\label{fig:1}+}+\end{figure}++\begin{figure}+\hypertarget{fig:2}{%+\centering+\includegraphics{fig2.png}+\caption{2}\label{fig:2}+}+\end{figure}++\begin{figure}+\hypertarget{fig:3}{%+\centering+\includegraphics{fig3.png}+\caption{3}\label{fig:3}+}+\end{figure}++\begin{figure}+\hypertarget{fig:4}{%+\centering+\includegraphics{fig4.png}+\caption{4}\label{fig:4}+}+\end{figure}++\begin{figure}+\hypertarget{fig:5}{%+\centering+\includegraphics{fig5.png}+\caption{5}\label{fig:5}+}+\end{figure}++\begin{figure}+\hypertarget{fig:6}{%+\centering+\includegraphics{fig6.png}+\caption{6}\label{fig:6}+}+\end{figure}++\begin{figure}+\hypertarget{fig:7}{%+\centering+\includegraphics{fig7.png}+\caption{7}\label{fig:7}+}+\end{figure}++\begin{figure}+\hypertarget{fig:8}{%+\centering+\includegraphics{fig8.png}+\caption{8}\label{fig:8}+}+\end{figure}++\begin{figure}+\hypertarget{fig:9}{%+\centering+\includegraphics{fig9.png}+\caption{9}\label{fig:9}+}+\end{figure}++\begin{codelisting}++\caption{Listing caption 1}++\hypertarget{lst:code1}{%+\label{lst:code1}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{codelisting}++\caption{Listing caption 2}++\hypertarget{lst:code2}{%+\label{lst:code2}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{codelisting}++\caption{Listing caption 3}++\hypertarget{lst:code3}{%+\label{lst:code3}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{codelisting}++\caption{Listing caption 4}++\hypertarget{lst:code4}{%+\label{lst:code4}}%+\begin{Shaded}+\begin{Highlighting}[]+\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}+\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}+\end{Highlighting}+\end{Shaded}++\end{codelisting}++\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}++\hypertarget{tbl:mytable}{}+\begin{longtable}[]{@{}lll@{}}+\caption{\label{tbl:mytable}My table}\tabularnewline+\toprule()+a & b & c \\+\midrule()+\endfirsthead+\toprule()+a & b & c \\+\midrule()+\endhead+1 & 2 & 3 \\+4 & 5 & 6 \\+\bottomrule()+\end{longtable}++\hypertarget{tbl:1}{}+\begin{longtable}[]{@{}ll@{}}+\caption{\label{tbl:1}Table}\tabularnewline+\toprule()+a & b \\+\midrule()+\endfirsthead+\toprule()+a & b \\+\midrule()+\endhead+1 & 2 \\+\bottomrule()+\end{longtable}++\listoffigures++\listoftables++\listoflistings
+ test/m2m/loxItemTitle/input.md view
@@ -0,0 +1,71 @@+---+lofItemTitle: "Figure "+lotItemTitle: "Title "+lolItemTemplate: "Listing $$i$$: $$t$$\\\n"+codeBlockCaptions: true+---++{#fig:1}++{#fig:2}++{#fig:3}++{#fig:4}++{#fig:5}++{#fig:6}++{#fig:7}++{#fig:8}++{#fig:9}++```haskell+main :: IO ()+main = putStrLn "Hello World!"+```+: Listing caption 1 {#lst:code1}++```haskell+main :: IO ()+main = putStrLn "Hello World!"+```++: Listing caption 2 {#lst:code2}++```{#lst:code3 .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```+: Listing caption 3++```{#lst:code4 .haskell}+main :: IO ()+main = putStrLn "Hello World!"+```++: Listing caption 4++***++a b c+--- --- ---+1 2 3+4 5 6++: My table {#tbl:mytable}++| a | b |+|---|---|+| 1 | 2 |++: Table {#tbl:1}++\listoffigures++\listoftables++\listoflistings
test/test-pandoc-crossref.hs view
@@ -236,11 +236,13 @@ it "Generates list of tables" $ testList (rawBlock "latex" "\\listoftables") (tblRefs =: M.fromList $ refRec' "tbl:1" 4 "4" <> refRec' "tbl:2" 5 "5" <> refRec' "tbl:3" 6 "6")- (header 1 (text "List of Tables") <> orderedList ((plain . str . T.pack . show) `map` [4..6 :: Int]))+ (header 1 (text "List of Tables") <> divWith ("", ["list", "list-of-tbl"], [])+ (mconcat $ map (\n -> plain (str (T.pack $ show n <> ".") <> space <> str (T.pack $ show n) <> linebreak)) [4..6 :: Int])) it "Generates list of figures" $ testList (rawBlock "latex" "\\listoffigures") (imgRefs =: M.fromList $ refRec' "fig:1" 4 "4" <> refRec' "fig:2" 5 "5" <> refRec' "fig:3" 6 "6")- (header 1 (text "List of Figures") <> orderedList ((plain . str . T.pack . show) `map` [4..6 :: Int]))+ (header 1 (text "List of Figures") <> divWith ("", ["list", "list-of-fig"], [])+ (mconcat $ map (\n -> plain (str (T.pack $ show n <> ".") <> space <> str (T.pack $ show n) <> linebreak)) [4..6 :: Int])) describe "Util.CodeBlockCaptions" $ it "Transforms table-style codeBlock captions to codeblock divs" $ do