+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+-}
+
+{-# LANGUAGE RecordWildCards, OverloadedStrings #-}
+
+module Text.Pandoc.CrossRef.Util.VarFunction where
+
+import Control.Applicative
+import Text.Pandoc.Definition
+import qualified Text.Pandoc.Builder as B
+
+import qualified Data.Text as T
+import Text.Pandoc.CrossRef.References.Types
+import Text.Pandoc.CrossRef.Util.Prefixes.Types
+
+defaultVarFunc :: (RefRec -> T.Text -> Maybe MetaValue)
+ -> RefRec -> T.Text -> Maybe MetaValue
+defaultVarFunc self RefRec{..} x = case x of
+ "idx" -> Just $ MetaString $ T.pack $ show refIndex
+ "ri" | null refIxInlRaw -> Nothing
+ | otherwise -> Just $ MetaInlines $ B.toList refIxInlRaw
+ "i" -> Just $ MetaInlines $ B.toList refIxInl
+ "t" -> Just $ MetaInlines $ B.toList refTitle
+ "lvl" -> Just $ MetaString $ T.pack $ show refLevel
+ "lbl" -> Just $ MetaString refLabel
+ "pfx" -> Just $ MetaString refPfx
+ _ | Just y <- T.stripPrefix "s." x
+ , Just rs <- refScope
+ -> self rs y
+ _ | Just y <- T.stripPrefix "def." x
+ -> prefixDef refPfxRec y
+ _ -> refAttrs x <|> prefixDef refPfxRec x
diff --git a/lib/Text/Pandoc/CrossRef.hs b/lib/Text/Pandoc/CrossRef.hs
index 10757502..4dd55eba 100644
--- a/lib/Text/Pandoc/CrossRef.hs
+++ b/lib/Text/Pandoc/CrossRef.hs
@@ -76,73 +76,65 @@ module Text.Pandoc.CrossRef (
, runCrossRefIO
, module SG
, defaultMeta
- , CrossRefM
+ , CrossRef
, CrossRefEnv(..)
+ , WSException(..)
+ , Settings(..)
) where
import Control.Monad.State
-import qualified Control.Monad.Reader as R
-import Text.Pandoc
+import Control.Monad.Except
+import Control.Monad.Writer as W
+import Control.Monad.Reader as R
+import Text.Pandoc as P
+import qualified Data.Text as T
+import qualified Data.Text.IO as T
+import System.IO
import Text.Pandoc.CrossRef.References
import Text.Pandoc.CrossRef.Util.Settings
-import Text.Pandoc.CrossRef.Util.Options as O
-import Text.Pandoc.CrossRef.Util.CodeBlockCaptions
import Text.Pandoc.CrossRef.Util.ModifyMeta
import Text.Pandoc.CrossRef.Util.Settings.Gen as SG
--- | Enviromnent for 'CrossRefM'
-data CrossRefEnv = CrossRefEnv {
- creSettings :: Meta -- ^Metadata settings
- , creOptions :: Options -- ^Internal pandoc-crossref options
- }
-
--- | Essentially a reader monad for basic pandoc-crossref environment
-type CrossRefM a = R.Reader CrossRefEnv a
-
{- | Walk over blocks, while inserting cross-references, list-of, etc.
Works in 'CrossRefM' monad. -}
-crossRefBlocks :: [Block] -> CrossRefM [Block]
-crossRefBlocks blocks = do
- opts <- R.asks creOptions
- let
- doWalk =
- bottomUpM (mkCodeBlockCaptions opts) blocks
- >>= replaceAll opts
- >>= bottomUpM (replaceRefs opts)
- >>= bottomUpM (listOf opts)
- (result, st) = runState doWalk def
- st `seq` return result
+crossRefBlocks :: [Block] -> CrossRef [Block]
+crossRefBlocks blocks = CrossRef $ do
+ (res, st) <- flip runStateT def $ unWS doWalk
+ st `seq` return res
+ where doWalk =
+ replaceAll blocks
+ >>= bottomUpM replaceRefs
+ >>= bottomUpM listOf
{- | Modifies metadata for LaTeX output, adding header-includes instructions
-to setup custom and builtin environments.
+to setup custom and builtin environments, and adds current pandoc-crossref
+settings to metadata.
-Note, that if output format is not "latex", this function does nothing.
+Note, that if output format is not "latex", this function not modify
+header-includes.
Works in 'CrossRefM' monad. -}
-crossRefMeta :: CrossRefM Meta
-crossRefMeta = do
- opts <- R.asks creOptions
- dtv <- R.asks creSettings
- return $ modifyMeta opts dtv
+crossRefMeta :: Meta -> CrossRef Meta
+crossRefMeta = modifyMeta
{- | Combines 'crossRefMeta' and 'crossRefBlocks'
Works in 'CrossRefM' monad. -}
-defaultCrossRefAction :: Pandoc -> CrossRefM Pandoc
-defaultCrossRefAction (Pandoc _ bs) = do
- meta' <- crossRefMeta
+defaultCrossRefAction :: Pandoc -> CrossRef Pandoc
+defaultCrossRefAction (Pandoc meta bs) = do
+ meta' <- crossRefMeta meta
bs' <- crossRefBlocks bs
return $ Pandoc meta' bs'
{- | Run an action in 'CrossRefM' monad with argument, and return pure result.
This is primary function to work with 'CrossRefM' -}
-runCrossRef :: forall a b. Meta -> Maybe Format -> (a -> CrossRefM b) -> a -> b
-runCrossRef meta fmt action arg = R.runReader (action arg) env
+runCrossRef :: forall b. Settings -> Maybe Format -> CrossRef b -> (Either WSException b, [T.Text])
+runCrossRef metaset fmt = flip runReader env . runWriterT . runExceptT . unCrossRef
where
- settings = defaultMeta <> meta
+ settings = metaset <> defaultMeta metaset
env = CrossRefEnv {
creSettings = settings
, creOptions = getOptions settings fmt
@@ -152,12 +144,9 @@ runCrossRef meta fmt action arg = R.runReader (action arg) env
This function will attempt to read pandoc-crossref settings from settings
file specified by crossrefYaml metadata field. -}
-runCrossRefIO :: forall a b. Meta -> Maybe Format -> (a -> CrossRefM b) -> a -> IO b
-runCrossRefIO meta fmt action arg = do
- settings <- getSettings fmt meta
- let
- env = CrossRefEnv {
- creSettings = settings
- , creOptions = getOptions settings fmt
- }
- return $ R.runReader (action arg) env
+runCrossRefIO :: forall b. Meta -> Maybe Format -> CrossRef b -> IO b
+runCrossRefIO meta fmt action = do
+ metaset <- readSettings fmt meta
+ let (res, lg) = runCrossRef metaset fmt action
+ mapM_ (T.hPutStrLn stderr) lg
+ return $ either (error . T.unpack . pretty) id res
diff --git a/package.yaml b/package.yaml
index b53d8270..56d9d3ca 100644
--- a/package.yaml
+++ b/package.yaml
@@ -1,5 +1,5 @@
name: pandoc-crossref
-version: '0.3.10.0'
+version: '0.4.0.0'
synopsis: Pandoc filter for cross-references
description: pandoc-crossref is a pandoc filter for numbering figures, equations,
tables and cross-references to them.
@@ -12,6 +12,7 @@ github: lierdakil/pandoc-crossref
extra-source-files:
- test/*.inc
- CHANGELOG.md
+- settings/*
data-files:
- docs/demo/demo.md
- docs/index.md
@@ -31,6 +32,7 @@ library:
- mtl >=1.1 && <2.3
internal-libraries:
pandoc-crossref-internal:
+ ghc-options: -Wall
source-dirs: lib-internal
dependencies:
- mtl >=1.1 && <2.3
@@ -45,6 +47,7 @@ internal-libraries:
- directory >=1 && <1.4
- filepath >=1.1 && <1.5
- template-haskell >=2.7.0.0 && <3.0.0.0
+ - bytestring
flags:
enable_flaky_tests:
description: Some tests rely on specific behaviour of pandoc, which
diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal
index 91f74d03..1f080bfb 100644
--- a/pandoc-crossref.cabal
+++ b/pandoc-crossref.cabal
@@ -4,10 +4,10 @@ cabal-version: 2.0
--
-- see: https://github.com/sol/hpack
--
--- hash: ab0ef9726844411ecb162895e5b7a5f58bb220f7af9f678463fa8ec333c55787
+-- hash: 031e4b85f89a0c982d26b289cc24dc3f6810e028780b70f70b9e08556bb67223
name: pandoc-crossref
-version: 0.3.10.0
+version: 0.4.0.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
@@ -19,72 +19,74 @@ license: GPL-2
license-file: LICENSE
build-type: Simple
extra-source-files:
- test/demo-chapters.inc
test/demo.inc
CHANGELOG.md
+ settings/chapters.yaml
+ settings/default.yaml
+ settings/numberSections.yaml
+ settings/subfigures.yaml
+ settings/titleSections.yaml
data-files:
docs/demo/demo.md
docs/index.md
+ test/m2m/capitalization/expect.md
+ test/m2m/capitalization/input.md
test/m2m/chapDelim/expect.md
- test/m2m/chapDelim/expect.tex
test/m2m/chapDelim/input.md
+ test/m2m/custom-prefixes/expect.md
+ test/m2m/custom-prefixes/input.md
test/m2m/delim/expect.md
- test/m2m/delim/expect.tex
test/m2m/delim/input.md
test/m2m/emptyChapterLabels/expect.md
- test/m2m/emptyChapterLabels/expect.tex
test/m2m/emptyChapterLabels/input.md
test/m2m/equations-auto/expect.md
- test/m2m/equations-auto/expect.tex
test/m2m/equations-auto/input.md
- test/m2m/equations-tables-auto/expect.md
- test/m2m/equations-tables-auto/expect.tex
- test/m2m/equations-tables-auto/input.md
- test/m2m/equations-tables/expect.md
- test/m2m/equations-tables/expect.tex
- test/m2m/equations-tables/input.md
test/m2m/equations/expect.md
- test/m2m/equations/expect.tex
test/m2m/equations/input.md
test/m2m/label-precedence/expect.md
- test/m2m/label-precedence/expect.tex
test/m2m/label-precedence/input.md
test/m2m/links-names/expect.md
- test/m2m/links-names/expect.tex
test/m2m/links-names/input.md
test/m2m/links/expect.md
- test/m2m/links/expect.tex
test/m2m/links/input.md
+ test/m2m/list-of/expect.md
+ test/m2m/list-of/input.md
test/m2m/listing-captions-ids/expect.md
- test/m2m/listing-captions-ids/expect.tex
test/m2m/listing-captions-ids/input.md
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/multiple-eqn-same-para/expect.md
- test/m2m/multiple-eqn-same-para/expect.tex
test/m2m/multiple-eqn-same-para/input.md
+ test/m2m/numbering-parts/expect.md
+ test/m2m/numbering-parts/input.md
+ test/m2m/ref-attrs/expect.md
+ test/m2m/ref-attrs/input.md
+ test/m2m/regresssion-219/expect.md
+ test/m2m/regresssion-219/input.md
+ test/m2m/scoping/expect.md
+ test/m2m/scoping/input.md
test/m2m/secLabels/expect.md
- test/m2m/secLabels/expect.tex
test/m2m/secLabels/input.md
test/m2m/secLevelLabels/expect.md
- test/m2m/secLevelLabels/expect.tex
test/m2m/secLevelLabels/input.md
test/m2m/section-template/expect.md
- test/m2m/section-template/expect.tex
test/m2m/section-template/input.md
test/m2m/setLabelAttribute/expect.md
- test/m2m/setLabelAttribute/expect.tex
test/m2m/setLabelAttribute/input.md
test/m2m/subfigures-ccsDelim/expect.md
- test/m2m/subfigures-ccsDelim/expect.tex
test/m2m/subfigures-ccsDelim/input.md
test/m2m/subfigures-grid/expect.md
- test/m2m/subfigures-grid/expect.tex
test/m2m/subfigures-grid/input.md
+ test/m2m/subfigures-template-collect/expect.md
+ test/m2m/subfigures-template-collect/input.md
test/m2m/subfigures/expect.md
- test/m2m/subfigures/expect.tex
test/m2m/subfigures/input.md
+ test/m2m/template-objects/expect.md
+ test/m2m/template-objects/input.md
+ test/m2m/template-options/expect.md
+ test/m2m/template-options/input.md
+ test/m2m/undefined-prefix/expect.md
+ test/m2m/undefined-prefix/input.md
source-repository head
type: git
@@ -118,23 +120,38 @@ library pandoc-crossref-internal
Text.Pandoc.CrossRef.References.Blocks
Text.Pandoc.CrossRef.References.List
Text.Pandoc.CrossRef.References.Refs
+ Text.Pandoc.CrossRef.References.Subfigures
Text.Pandoc.CrossRef.References.Types
+ Text.Pandoc.CrossRef.References.Types.Monad
+ Text.Pandoc.CrossRef.References.Types.Ref
Text.Pandoc.CrossRef.Util.CodeBlockCaptions
Text.Pandoc.CrossRef.Util.CustomLabels
Text.Pandoc.CrossRef.Util.Meta
Text.Pandoc.CrossRef.Util.ModifyMeta
Text.Pandoc.CrossRef.Util.Options
+ Text.Pandoc.CrossRef.Util.Options.Types
+ Text.Pandoc.CrossRef.Util.Prefixes
+ Text.Pandoc.CrossRef.Util.Prefixes.Types
+ Text.Pandoc.CrossRef.Util.Replace
Text.Pandoc.CrossRef.Util.Settings
+ Text.Pandoc.CrossRef.Util.Settings.Embed
Text.Pandoc.CrossRef.Util.Settings.Gen
+ Text.Pandoc.CrossRef.Util.Settings.LiftPandoc
Text.Pandoc.CrossRef.Util.Settings.Template
+ Text.Pandoc.CrossRef.Util.Settings.Types
+ Text.Pandoc.CrossRef.Util.Settings.Util
Text.Pandoc.CrossRef.Util.Template
+ Text.Pandoc.CrossRef.Util.Template.Types
Text.Pandoc.CrossRef.Util.Util
+ Text.Pandoc.CrossRef.Util.VarFunction
other-modules:
Paths_pandoc_crossref
hs-source-dirs:
lib-internal
+ ghc-options: -Wall
build-depends:
base >=4.11 && <5
+ , bytestring
, 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
diff --git a/settings/chapters.yaml b/settings/chapters.yaml
new file mode 100644
index 00000000..46c2acb2
--- /dev/null
+++ b/settings/chapters.yaml
@@ -0,0 +1,8 @@
+captionIndexTemplate: $$s.i%.$$$$ri$$
+scope: sec
+prefixes:
+ sec:
+ title: Chapter
+ sub:
+ title: Section
+ referenceIndexTemplate: $$i$$$$suf$$
diff --git a/settings/default.yaml b/settings/default.yaml
new file mode 100644
index 00000000..e1b92559
--- /dev/null
+++ b/settings/default.yaml
@@ -0,0 +1,45 @@
+codeBlockCaptions: False
+adjustSectionIdentifiers: False
+autoSectionLabels: sec
+titleDelim: ":[]{.s}"
+listItemNumberDelim: ".[]{.s}"
+rangeDelim: "-"
+pairDelim: ",[]{.s}"
+lastDelim: ",[]{.s}"
+refDelim: ",[]{.s}"
+crossrefYaml: "pandoc-crossref.yaml"
+linkReferences: False
+nameInLink: False
+collectedCaptionDelim: ",[]{.s}"
+collectedCaptionItemDelim: "[]{.s}--[]{.s}"
+# these are merely the defaults, can (and will) be overridden in prefix configs
+captionTemplate: "$$title%\u00a0$$$$i$$$$titleDelim$$$$t$$"
+captionIndexTemplate: $$ri$$
+referenceTemplate: "$$Ref[n]%\u00a0$$$$rs$$"
+listItemTemplate: $$i$$$$listItemNumberDelim$$$$t$$
+collectedCaptionTemplate: $$i$$$$collectedCaptionItemDelim$$$$t$$
+referenceIndexTemplate: $$i$$$$suf$$
+listOfTitle: |
+ # List of $$title$$s
+numbering: arabic
+prefixes:
+ eq:
+ ref: ["eq.", "eqns."]
+ captionTemplate: "$$t$$\\\\qquad($$i$$)"
+ title: Equation
+ fig:
+ ref: ["fig.", "figs."]
+ title: Figure
+ lst:
+ ref: ["lst.", "lsts."]
+ title: Listing
+ captionPosition: above
+ tbl:
+ ref: ["tbl.", "tbls."]
+ title: Table
+ sec:
+ ref: ["sec.", "secs."]
+ title: Section
+ captionTemplate: $$t$$
+ scope: sec
+ referenceIndexTemplate: $$s.refi%.$$$$i$$$$suf$$
diff --git a/settings/numberSections.yaml b/settings/numberSections.yaml
new file mode 100644
index 00000000..29036137
--- /dev/null
+++ b/settings/numberSections.yaml
@@ -0,0 +1,8 @@
+chapDelim: .
+prefixes:
+ sec:
+ captionTemplate: $$i$$ $$t$$
+ captionIndexTemplate: $$ri$$
+ referenceIndexTemplate: $$i$$$$suf$$
+ sub:
+ captionIndexTemplate: $$s.i$$$$ri#`chapDelim`$$
diff --git a/settings/subfigures.yaml b/settings/subfigures.yaml
new file mode 100644
index 00000000..fa3a9f38
--- /dev/null
+++ b/settings/subfigures.yaml
@@ -0,0 +1,10 @@
+prefixes:
+ fig:
+ subcaptions: True
+ sub:
+ numbering: alpha a
+ referenceIndexTemplate: $$s.i$$($$i$$)
+ listItemTemplate: $$s.i$$($$i$$)$$listItemNumberDelim$$$$t$$
+ captionTemplate: $$i$$
+ scope: fig
+ captionIndexTemplate: $$ri$$
diff --git a/settings/titleSections.yaml b/settings/titleSections.yaml
new file mode 100644
index 00000000..11ee2fa7
--- /dev/null
+++ b/settings/titleSections.yaml
@@ -0,0 +1,3 @@
+prefixes:
+ sec:
+ captionTemplate: $$title$$ $$i$$. $$t$$
diff --git a/src/pandoc-crossref.hs b/src/pandoc-crossref.hs
index 388f0c05..930274a4 100644
--- a/src/pandoc-crossref.hs
+++ b/src/pandoc-crossref.hs
@@ -92,7 +92,7 @@ run = do
, "instead."
]
toJSONFilter (f fmt)
- f fmt p@(Pandoc meta _) = runCrossRefIO meta (Format . T.pack <$> fmt) defaultCrossRefAction p
+ f fmt p@(Pandoc meta _) = runCrossRefIO meta (Format . T.pack <$> fmt) $ defaultCrossRefAction p
main :: IO ()
main = join $ execParser opts
diff --git a/test/Native.hs b/test/Native.hs
index bf16e0f4..dcd79ac1 100644
--- a/test/Native.hs
+++ b/test/Native.hs
@@ -23,9 +23,7 @@ module Native where
import Text.Pandoc.Definition
-demo, demochapters :: [Block]
+demo :: [Block]
demo =
#include "demo.inc"
-demochapters =
-#include "demo-chapters.inc"
diff --git a/test/demo-chapters.inc b/test/demo-chapters.inc
deleted file mode 100644
index a8c1aa21..00000000
--- a/test/demo-chapters.inc
+++ /dev/null
@@ -1,114 +0,0 @@
- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&1.1-1.3),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&2.1),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&3.1)",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "4.1-4.3)"]
- ,Para [Str "For",Space,Str "immediate",Space,Str "example,",Space,Str "see",Space,Str "fig.\160\&1"]
- ,Para [Image ("fig:figure0",[],[]) [Str "Figure",Space,Str "#",Space,Str "1:",Space,Str "A",Space,Str "figure"] ("img1.jpg","fig:")]
- ,Para [Str "There",Space,Str "is",Space,Str "also",Space,Str "support",Space,Str "for",Space,Str "code",Space,Str "blocks,",Space,Str "for",Space,Str "example,",Space,Str "lsts.\160\&4.1-4.3"]
- ,Para [Str "It\8217s",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&1.1."]
- ,Para [Str "In",Space,Str "case",Space,Str "of",Space,Str "multiple",Space,Str "references,",Space,Str "capitalization",Space,Str "is",Space,Str "determined",Space,Str "by",Space,Str "first",Space,Str "reference.",Space,Str "Figs.\160\&1.1,",Space,Str "1.2",Space,Str "is",Space,Str "capitalized,",Space,Str "while",Space,Str "figs.\160\&1.1,",Space,Str "1.2",Space,Str "is",Space,Str "not."]
- ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&1.1,",Space,Str "tbl.\160\&3.1,",Space,Str "lsts.\160\&4.1,",Space,Str "4.2,",Space,Str "figs.\160\&1.2,",Space,Str "1.3,",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it\8217s",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&1.1,",Space,Str "tbl.\160\&3.1,",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 11, citationHash = 0}] [Str "[@unprocessedCitation]"]]
- ,Para [Str "You",Space,Str "can",Space,Str "also",Space,Str "have",Space,Str "custom",Space,Str "chapter",Space,Str "reference",Space,Str "labels,",Space,Str "like",Space,Str "sec.\160AppA.CustLab"]
- ,Para [Str "Subfigures",Space,Str "are",Space,Str "supported,",Space,Str "see",Space,Str "figs.\160\&1.4,",Space,Str "1.4",Space,Str "(b)"]
- ,Header 1 ("sec:sec1",[],[]) [Str "Chapter",Space,Str "1.",Space,Str "Figures"]
- ,Para [Image ("fig:figure1",[],[]) [Str "Figure",Space,Str "#",Space,Str "1.1:",Space,Str "First",Space,Str "figure"] ("img1.jpg","fig:")]
- ,Para [Image ("fig:figure2",[],[]) [Str "Figure",Space,Str "#",Space,Str "1.2:",Space,Str "Second",Space,Str "figure"] ("img2.jpg","fig:")]
- ,Para [Image ("fig:figure3",[],[]) [Str "Figure",Space,Str "#",Space,Str "1.3:",Space,Str "Third",Space,Str "figure"] ("img3.jpg","fig:")]
- ,Para [Image ("",[],[]) [Str "Unlabelled",Space,Str "image"] ("img1.jpg","fig:")]
- ,Div ("fig:subfigures",["subfigures"],[])
- [Para [Image ("",[],[]) [Str "a"] ("img1.jpg","fig:")]
- ,Para [Image ("fig:subfigureB",[],[]) [Str "b"] ("img1.jpg","fig:")]
- ,Para [Str "Figure",Space,Str "#",Space,Str "1.4:",Space,Str "Subfigures",Space,Str "caption.",Space,Str "a",Space,Str "\8212",Space,Str "Subfigure",Space,Str "a,",Space,Str "b",Space,Str "\8212",Space,Str "Subfigure",Space,Str "b"]]
- ,Header 1 ("sec:sec2",[],[]) [Str "Chapter",Space,Str "2.",Space,Str "Equations"]
- ,Para [Str "Display",Space,Str "equations",Space,Str "are",Space,Str "labelled",Space,Str "and",Space,Str "numbered"]
- ,Para [Span ("eq:eqn1",[],[]) [Math DisplayMath " P_i(x) = \\sum_i a_i x^i \\qquad(2.1)"]]
- ,Para [Str "Since",Space,Str "0.1.6.0",Space,Str "those",Space,Str "can",Space,Str "also",Space,Str "appear",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "paragraph",SoftBreak,Span ("eq:quadr",[],[]) [Math DisplayMath "a x^2 + b x^2 + c = 0\\qquad(2.2)"],Space,Str "like",Space,Str "this."]
- ,Header 1 ("sec:chapter-3.-tables",[],[]) [Str "Chapter",Space,Str "3.",Space,Str "Tables"]
- ,Div ("tbl:table1",[],[])
- [Table ("",[],[]) (Caption Nothing
- [Plain [Emph [Str "Table",Space,Str "3.1"],Str ":",Space,Str "Table",Space,Str "example"]])
- [(AlignLeft,ColWidthDefault)
- ,(AlignLeft,ColWidthDefault)]
- (TableHead ("",[],[])
- [Row ("",[],[])
- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "First",Space,Str "Header"]]
- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Second",Space,Str "Header"]]]])
- [(TableBody ("",[],[]) (RowHeadColumns 0)
- []
- [Row ("",[],[])
- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]
- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]]
- ,Row ("",[],[])
- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]
- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]]])]
- (TableFoot ("",[],[])
- [])]
- ,Para [Str "Table",Space,Str "without",Space,Str "caption:"]
- ,Table ("",[],[]) (Caption Nothing
- [])
- [(AlignLeft,ColWidthDefault)
- ,(AlignLeft,ColWidthDefault)]
- (TableHead ("",[],[])
- [Row ("",[],[])
- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "First",Space,Str "Header"]]
- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Second",Space,Str "Header"]]]])
- [(TableBody ("",[],[]) (RowHeadColumns 0)
- []
- [Row ("",[],[])
- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]
- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]]
- ,Row ("",[],[])
- [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]
- ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
- [Plain [Str "Content",Space,Str "Cell"]]]])]
- (TableFoot ("",[],[])
- [])
- ,Header 1 ("sec:chapter-4.-code-blocks",[],[]) [Str "Chapter",Space,Str "4.",Space,Str "Code",Space,Str "blocks"]
- ,Para [Str "There",Space,Str "are",Space,Str "a",Space,Str "couple",Space,Str "options",Space,Str "for",Space,Str "code",Space,Str "block",Space,Str "labels.",Space,Str "Those",Space,Str "work",Space,Str "only",Space,Str "if",Space,Str "code",Space,Str "block",Space,Str "id",Space,Str "starts",Space,Str "with",Space,Code ("",[],[]) "lst:",Str ",",Space,Str "e.g.\160",Code ("",[],[]) "{#lst:label}"]
- ,Header 2 ("sec:caption-attr",[],[]) [Code ("",[],[]) "caption",Space,Str "attribute"]
- ,Para [Code ("",[],[]) "caption",Space,Str "attribute",Space,Str "will",Space,Str "be",Space,Str "treated",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption.",Space,Str "If",Space,Str "code",Space,Str "block",Space,Str "has",Space,Str "both",Space,Str "id",Space,Str "and",Space,Code ("",[],[]) "caption",Space,Str "attributes,",Space,Str "it",Space,Str "will",Space,Str "be",Space,Str "treated",Space,Str "as",Space,Str "numbered",Space,Str "code",Space,Str "block."]
- ,Div ("lst:captionAttr",["listing","haskell"],[])
- [Para [Str "Listing",Space,Str "4.1:",Space,Str "Listing",Space,Str "caption"]
- ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
- ,RawBlock (Format "tex") "\\pagebreak"
- ,Header 2 ("sec:table-capts",[],[]) [Str "Table-style",Space,Str "captions"]
- ,Para [Str "Enabled",Space,Str "with",Space,Code ("",[],[]) "codeBlockCaptions",Space,Str "metadata",Space,Str "option.",Space,Str "If",Space,Str "code",Space,Str "block",Space,Str "is",Space,Str "immediately",SoftBreak,Str "adjacent",Space,Str "to",Space,Str "paragraph,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "Listing:",Space,Str "or",Space,Code ("",[],[]) ":",Str ",",Space,Str "said",Space,Str "paragraph",Space,Str "will",Space,Str "be",SoftBreak,Str "treated",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."]
- ,Div ("lst:tableCaption",["listing","haskell"],[])
- [Para [Str "Listing",Space,Str "4.2:",Space,Str "Listing",Space,Str "caption"]
- ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
- ,Header 2 ("sec:wrapping-div",[],[]) [Str "Wrapping",Space,Str "div"]
- ,Para [Str "Wrapping",Space,Str "code",Space,Str "block",Space,Str "without",Space,Str "label",Space,Str "in",Space,Str "a",Space,Str "div",Space,Str "with",Space,Str "id",Space,Code ("",[],[]) "lst:...",Space,Str "and",Space,Str "class,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "listing",Str ",",Space,Str "and",Space,Str "adding",Space,Str "paragraph",Space,Str "before",Space,Str "code",Space,Str "block,",Space,Str "but",Space,Str "inside",Space,Str "div,",Space,Str "will",Space,Str "treat",Space,Str "said",Space,Str "paragraph",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."]
- ,Div ("lst:wrappingDiv",["listing","haskell"],[])
- [Para [Str "Listing",Space,Str "4.3:",Space,Str "Listing",Space,Str "caption"]
- ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
- ,Header 1 ("sec:unnumbered-chapter.",["unnumbered"],[]) [Str "Unnumbered",Space,Str "chapter."]
- ,Para [Str "This",Space,Str "chapter",Space,Str "doesn\8217t",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(4.1)"]]
- ,Header 1 ("sec:chapter-5.-reference-lists",[],[]) [Str "Chapter",Space,Str "5.",Space,Str "Reference",Space,Str "lists"]
- ,Para [Str "It\8217s",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "show",Space,Str "lists",Space,Str "of",Space,Str "figures",Space,Str "and",Space,Str "tables,",Space,Str "like",Space,Str "this:"]
- ,Header 2 ("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",Space,Str "Subfigures",Space,Str "caption"]]
- ,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"]]
- ,Header 1 ("",[],[]) [Str "List",Space,Str "of",Space,Str "Listings"]
- ,Div ("",["list"],[])
- [Para [Str "4.1",Space,Str "Listing",Space,Str "caption"]
- ,Para [Str "4.2",Space,Str "Listing",Space,Str "caption"]
- ,Para [Str "4.3",Space,Str "Listing",Space,Str "caption"]]
- ,Header 1 ("sec:appendix-a.-custom-labels",[],[("label","AppA")]) [Str "Appendix",Space,Str "A.",Space,Str "Custom",Space,Str "labels"]
- ,Header 2 ("sec:custlabs",[],[("label","CustLab")]) [Str "This",Space,Str "section",Space,Str "will",Space,Str "have",Space,Str "custom",Space,Str "label"]]
diff --git a/test/demo.inc b/test/demo.inc
index 9fea08b4..21eb1696 100644
--- a/test/demo.inc
+++ b/test/demo.inc
@@ -1,29 +1,44 @@
- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&2-4),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&1),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&1)",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "4.1-4.3)"]
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "demo",Space,Str "file",Space,Str "for",Space,Str "pandoc-crossref.",Space,Str "With",Space,Str "this",Space,Str "filter,",Space,Str "you",Space,Str "can",Space,Str "cross-reference",Space,Str "figures",Space,Str "(see",Space,Str "figs.\160\&1.1-1.3),",Space,Str "display",Space,Str "equations",Space,Str "(see",Space,Str "eq.\160\&2.1),",Space,Str "tables",Space,Str "(see",Space,Str "tbl.\160\&3.1)",Space,Str "and",Space,Str "sections",Space,Str "(",Str "secs.\160\&1,",Space,Str "2,",Space,Str "secs.\160\&4.1-4.3)"]
,Para [Str "For",Space,Str "immediate",Space,Str "example,",Space,Str "see",Space,Str "fig.\160\&1"]
- ,Para [Image ("fig:figure0",[],[]) [Str "Figure",Space,Str "#",Space,Str "1:",Space,Str "A",Space,Str "figure"] ("img1.jpg","fig:")]
- ,Para [Str "There",Space,Str "is",Space,Str "also",Space,Str "support",Space,Str "for",Space,Str "code",Space,Str "blocks,",Space,Str "for",Space,Str "example,",Space,Str "lsts.\160\&1-3"]
- ,Para [Str "It\8217s",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&2."]
- ,Para [Str "In",Space,Str "case",Space,Str "of",Space,Str "multiple",Space,Str "references,",Space,Str "capitalization",Space,Str "is",Space,Str "determined",Space,Str "by",Space,Str "first",Space,Str "reference.",Space,Str "Figs.\160\&2,",Space,Str "3",Space,Str "is",Space,Str "capitalized,",Space,Str "while",Space,Str "figs.\160\&2,",Space,Str "3",Space,Str "is",Space,Str "not."]
- ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&2,",Space,Str "tbl.\160\&1,",Space,Str "lsts.\160\&1,",Space,Str "2,",Space,Str "figs.\160\&3,",Space,Str "4,",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it\8217s",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&2,",Space,Str "tbl.\160\&1,",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 11, citationHash = 0}] [Str "[@unprocessedCitation]"]]
- ,Para [Str "You",Space,Str "can",Space,Str "also",Space,Str "have",Space,Str "custom",Space,Str "chapter",Space,Str "reference",Space,Str "labels,",Space,Str "like",Space,Str "sec.\160AppA.CustLab"]
- ,Para [Str "Subfigures",Space,Str "are",Space,Str "supported,",Space,Str "see",Space,Str "figs.\160\&5,",Space,Str "5",Space,Str "(b)"]
+ ,Para [Image ("fig:figure0",[],[]) [Str "Figure\160\&1:",Space,Str "A",Space,Str "figure"] ("img1.jpg","fig:")]
+ ,Para [Str "There",Space,Str "is",Space,Str "also",Space,Str "support",Space,Str "for",Space,Str "code",Space,Str "blocks,",Space,Str "for",Space,Str "example,",Space,Str "lsts.\160\&4.1.1,",Space,Str "4.2.1,",Space,Str "4.3.1"]
+ ,Para [Str "It\8217s",Space,Str "possible",Space,Str "to",Space,Str "capitalize",Space,Str "reference",Space,Str "prefixes,",Space,Str "like",Space,Str "this:",Space,Str "Fig.\160\&1.1."]
+ ,Para [Str "In",Space,Str "case",Space,Str "of",Space,Str "multiple",Space,Str "references,",Space,Str "capitalization",Space,Str "is",Space,Str "determined",Space,Str "by",Space,Str "first",Space,Str "reference.",Space,Str "Figs.\160\&1.1,",Space,Str "1.2",Space,Str "is",Space,Str "capitalized,",Space,Str "while",Space,Str "figs.\160\&1.1,",Space,Str "1.2",Space,Str "is",Space,Str "not."]
+ ,Para [Str "It",Space,Str "is",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "mix",Space,Str "different",Space,Str "references,",Space,Str "like",Space,Str "fig.\160\&1.1,",Space,Str "tbl.\160\&3.1,",Space,Str "lsts.\160\&4.1.1,",Space,Str "4.2.1,",Space,Str "figs.\160\&1.2,",Space,Str "1.3,",Space,Str "which",Space,Str "will",Space,Str "be",Space,Str "grouped",Space,Str "in",Space,Str "order",Space,Str "they",Space,Str "are",Space,Str "specified.",Space,Str "You",Space,Str "can",Space,Str "even",Space,Str "intermix",Space,Str "this",Space,Str "with",Space,Str "regular",Space,Str "citations,",Space,Str "although",Space,Str "it\8217s",Space,Str "not",Space,Str "recommended:",Space,Str "fig.\160\&1.1,",Space,Str "tbl.\160\&3.1,",Space,Cite [Citation {citationId = "unprocessedCitation", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 11, citationHash = 0}] [Str "[@unprocessedCitation]"]]
+ ,Para [Str "You",Space,Str "can",Space,Str "also",Space,Str "have",Space,Str "custom",Space,Str "chapter",Space,Str "reference",Space,Str "labels,",Space,Str "like",Space,Str "sec.\160A.I"]
+ ,Para [Str "Subfigures",Space,Str "are",Space,Str "supported,",Space,Str "see",Space,Str "fig.\160\&1.5,",Space,Str "fig.\160\&1.5(b)"]
,Header 1 ("sec:sec1",[],[]) [Str "Chapter",Space,Str "1.",Space,Str "Figures"]
- ,Para [Image ("fig:figure1",[],[]) [Str "Figure",Space,Str "#",Space,Str "2:",Space,Str "First",Space,Str "figure"] ("img1.jpg","fig:")]
- ,Para [Image ("fig:figure2",[],[]) [Str "Figure",Space,Str "#",Space,Str "3:",Space,Str "Second",Space,Str "figure"] ("img2.jpg","fig:")]
- ,Para [Image ("fig:figure3",[],[]) [Str "Figure",Space,Str "#",Space,Str "4:",Space,Str "Third",Space,Str "figure"] ("img3.jpg","fig:")]
- ,Para [Image ("",[],[]) [Str "Unlabelled",Space,Str "image"] ("img1.jpg","fig:")]
- ,Div ("fig:subfigures",["subfigures"],[])
- [Para [Image ("",[],[]) [Str "a"] ("img1.jpg","fig:")]
- ,Para [Image ("fig:subfigureB",[],[]) [Str "b"] ("img1.jpg","fig:")]
- ,Para [Str "Figure",Space,Str "#",Space,Str "5:",Space,Str "Subfigures",Space,Str "caption.",Space,Str "a",Space,Str "\8212",Space,Str "Subfigure",Space,Str "a,",Space,Str "b",Space,Str "\8212",Space,Str "Subfigure",Space,Str "b"]]
+ ,Para [Image ("fig:figure1",[],[]) [Str "Figure\160\&1.1:",Space,Str "First",Space,Str "figure"] ("img1.jpg","fig:")]
+ ,Para [Image ("fig:figure2",[],[]) [Str "Figure\160\&1.2:",Space,Str "Second",Space,Str "figure"] ("img2.jpg","fig:")]
+ ,Para [Image ("fig:figure3",[],[]) [Str "Figure\160\&1.3:",Space,Str "Third",Space,Str "figure"] ("img3.jpg","fig:")]
+ ,Para [Image ("",[],[]) [Str "Figure\160\&1.4:",Space,Str "Unlabelled",Space,Str "image"] ("img1.jpg","fig:")]
+ ,Div ("fig:subfigures",["subcaption"],[])
+ [Table ("",[],[]) (Caption Nothing
+ [])
+ [(AlignCenter,ColWidth 0.99)]
+ (TableHead ("",[],[])
+ [])
+ [(TableBody ("",[],[]) (RowHeadColumns 0)
+ []
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 0) (ColSpan 0)
+ [Div ("",[],[])
+ [Para [Image ("",[],[("width","100%")]) [Str "a"] ("img1.jpg","fig:")]]]]
+ ,Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 0) (ColSpan 0)
+ [Div ("",[],[])
+ [Para [Image ("fig:subfigureB",[],[("width","100%")]) [Str "b"] ("img1.jpg","fig:")]]]]])]
+ (TableFoot ("",[],[])
+ [])
+ ,Para [Str "Figure\160\&1.5:",Space,Str "Subfigures",Space,Str "caption.",Space,Span ("",[],[]) [Str "a",Space,Str "\8211",Space,Str "Subfigure",Space,Str "a,",Space,Str "b",Space,Str "\8211",Space,Str "Subfigure",Space,Str "b"]]]
,Header 1 ("sec:sec2",[],[]) [Str "Chapter",Space,Str "2.",Space,Str "Equations"]
,Para [Str "Display",Space,Str "equations",Space,Str "are",Space,Str "labelled",Space,Str "and",Space,Str "numbered"]
- ,Para [Span ("eq:eqn1",[],[]) [Math DisplayMath " P_i(x) = \\sum_i a_i x^i \\qquad(1)"]]
- ,Para [Str "Since",Space,Str "0.1.6.0",Space,Str "those",Space,Str "can",Space,Str "also",Space,Str "appear",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "paragraph",SoftBreak,Span ("eq:quadr",[],[]) [Math DisplayMath "a x^2 + b x^2 + c = 0\\qquad(2)"],Space,Str "like",Space,Str "this."]
- ,Header 1 ("sec:chapter-3.-tables",[],[]) [Str "Chapter",Space,Str "3.",Space,Str "Tables"]
+ ,Para [Span ("eq:eqn1",[],[]) [Math DisplayMath " P_i(x) = \\sum_i a_i x^i \\qquad(2.1)"]]
+ ,Para [Str "Since",Space,Str "0.1.6.0",Space,Str "those",Space,Str "can",Space,Str "also",Space,Str "appear",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "paragraph",SoftBreak,Span ("eq:quadr",[],[]) [Math DisplayMath "a x^2 + b x^2 + c = 0\\qquad(2.2)"],Space,Str "like",Space,Str "this."]
+ ,Header 1 ("sec:tables",[],[]) [Str "Chapter",Space,Str "3.",Space,Str "Tables"]
,Div ("tbl:table1",[],[])
[Table ("",[],[]) (Caption Nothing
- [Plain [Emph [Str "Table",Space,Str "1"],Str ":",Space,Str "Table",Space,Str "example"]])
+ [Plain [Str "Table\160\&3.1:",Space,Str "Table",Space,Str "example"]])
[(AlignLeft,ColWidthDefault)
,(AlignLeft,ColWidthDefault)]
(TableHead ("",[],[])
@@ -71,44 +86,45 @@
[Plain [Str "Content",Space,Str "Cell"]]]])]
(TableFoot ("",[],[])
[])
- ,Header 1 ("sec:chapter-4.-code-blocks",[],[]) [Str "Chapter",Space,Str "4.",Space,Str "Code",Space,Str "blocks"]
+ ,Header 1 ("sec:code-blocks",[],[]) [Str "Chapter",Space,Str "4.",Space,Str "Code",Space,Str "blocks"]
,Para [Str "There",Space,Str "are",Space,Str "a",Space,Str "couple",Space,Str "options",Space,Str "for",Space,Str "code",Space,Str "block",Space,Str "labels.",Space,Str "Those",Space,Str "work",Space,Str "only",Space,Str "if",Space,Str "code",Space,Str "block",Space,Str "id",Space,Str "starts",Space,Str "with",Space,Code ("",[],[]) "lst:",Str ",",Space,Str "e.g.\160",Code ("",[],[]) "{#lst:label}"]
- ,Header 2 ("sec:caption-attr",[],[]) [Code ("",[],[]) "caption",Space,Str "attribute"]
+ ,Header 2 ("sec:caption-attr",[],[]) [Str "Section",Space,Str "4.1.",Space,Code ("",[],[]) "caption",Space,Str "attribute"]
,Para [Code ("",[],[]) "caption",Space,Str "attribute",Space,Str "will",Space,Str "be",Space,Str "treated",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption.",Space,Str "If",Space,Str "code",Space,Str "block",Space,Str "has",Space,Str "both",Space,Str "id",Space,Str "and",Space,Code ("",[],[]) "caption",Space,Str "attributes,",Space,Str "it",Space,Str "will",Space,Str "be",Space,Str "treated",Space,Str "as",Space,Str "numbered",Space,Str "code",Space,Str "block."]
- ,Div ("lst:captionAttr",["listing","haskell"],[])
- [Para [Str "Listing",Space,Str "1:",Space,Str "Listing",Space,Str "caption"]
+ ,Div ("lst:captionAttr",[],[])
+ [Para [Str "Listing\160\&4.1.1:",Space,Str "Listing",Space,Str "caption"]
,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
,RawBlock (Format "tex") "\\pagebreak"
- ,Header 2 ("sec:table-capts",[],[]) [Str "Table-style",Space,Str "captions"]
+ ,Header 2 ("sec:table-capts",[],[]) [Str "Section",Space,Str "4.2.",Space,Str "Table-style",Space,Str "captions"]
,Para [Str "Enabled",Space,Str "with",Space,Code ("",[],[]) "codeBlockCaptions",Space,Str "metadata",Space,Str "option.",Space,Str "If",Space,Str "code",Space,Str "block",Space,Str "is",Space,Str "immediately",SoftBreak,Str "adjacent",Space,Str "to",Space,Str "paragraph,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "Listing:",Space,Str "or",Space,Code ("",[],[]) ":",Str ",",Space,Str "said",Space,Str "paragraph",Space,Str "will",Space,Str "be",SoftBreak,Str "treated",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."]
- ,Div ("lst:tableCaption",["listing","haskell"],[])
- [Para [Str "Listing",Space,Str "2:",Space,Str "Listing",Space,Str "caption"]
- ,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
- ,Header 2 ("sec:wrapping-div",[],[]) [Str "Wrapping",Space,Str "div"]
- ,Para [Str "Wrapping",Space,Str "code",Space,Str "block",Space,Str "without",Space,Str "label",Space,Str "in",Space,Str "a",Space,Str "div",Space,Str "with",Space,Str "id",Space,Code ("",[],[]) "lst:...",Space,Str "and",Space,Str "class,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "listing",Str ",",Space,Str "and",Space,Str "adding",Space,Str "paragraph",Space,Str "before",Space,Str "code",Space,Str "block,",Space,Str "but",Space,Str "inside",Space,Str "div,",Space,Str "will",Space,Str "treat",Space,Str "said",Space,Str "paragraph",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."]
- ,Div ("lst:wrappingDiv",["listing","haskell"],[])
- [Para [Str "Listing",Space,Str "3:",Space,Str "Listing",Space,Str "caption"]
+ ,Div ("lst:tableCaption",[],[])
+ [Para [Str "Listing\160\&4.2.1:",Space,Str "Listing",Space,Str "caption"]
,CodeBlock ("",["haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
+ ,Header 2 ("sec:wrapping-div",[],[]) [Str "Section",Space,Str "4.3.",Space,Str "Wrapping",Space,Str "div"]
+ ,Para [Str "Wrapping",Space,Str "code",Space,Str "block",Space,Str "without",Space,Str "label",Space,Str "in",Space,Str "a",Space,Str "div",Space,Str "with",Space,Str "id",Space,Code ("",[],[]) "lst:...",Space,Str "and",Space,Str "class,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) "listing",Str ",",Space,Str "and",Space,Str "adding",Space,Str "paragraph",Space,Str "after",Space,Str "code",Space,Str "block,",Space,Str "but",Space,Str "inside",Space,Str "div,",Space,Str "starting",Space,Str "with",Space,Code ("",[],[]) ":",Space,Str "will",Space,Str "treat",Space,Str "said",Space,Str "paragraph",Space,Str "as",Space,Str "code",Space,Str "block",Space,Str "caption."]
+ ,Div ("lst:wrappingDiv",["listing"],[])
+ [Para [Str "Listing\160\&4.3.1:",Space,Str "Listing",Space,Str "caption"]
+ ,CodeBlock ("",["listing","haskell"],[]) "main :: IO ()\nmain = putStrLn \"Hello World!\""]
,Header 1 ("sec:unnumbered-chapter.",["unnumbered"],[]) [Str "Unnumbered",Space,Str "chapter."]
- ,Para [Str "This",Space,Str "chapter",Space,Str "doesn\8217t",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(3)"]]
- ,Header 1 ("sec:chapter-5.-reference-lists",[],[]) [Str "Chapter",Space,Str "5.",Space,Str "Reference",Space,Str "lists"]
+ ,Para [Str "This",Space,Str "chapter",Space,Str "doesn\8217t",Space,Str "change",Space,Str "chapter",Space,Str "prefix",Space,Str "of",Space,Str "referenced",Space,Str "elements,",Space,Str "instead",Space,Str "keeping",Space,Str "number",Space,Str "of",Space,Str "previous",Space,Str "chapter,",Space,Str "e.g.",SoftBreak,Span ("eq:eqn2",[],[]) [Math DisplayMath " S(x) = \\int_{x_1}^{x_2} a x+b \\ \\mathrm{d}x \\qquad(1)"]]
+ ,Header 1 ("sec:reference-lists",[],[]) [Str "Chapter",Space,Str "5.",Space,Str "Reference",Space,Str "lists"]
,Para [Str "It\8217s",Space,Str "also",Space,Str "possible",Space,Str "to",Space,Str "show",Space,Str "lists",Space,Str "of",Space,Str "figures",Space,Str "and",Space,Str "tables,",Space,Str "like",Space,Str "this:"]
- ,Header 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"]]]
- ,Header 2 ("list-of-tables",[],[]) [Str "List",Space,Str "of",Space,Str "Tables"]
- ,OrderedList (1,DefaultStyle,DefaultDelim)
- [[Plain [Str "Table",Space,Str "example"]]]
+ ,Header 1 ("",[],[]) [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 "Unlabelled",Space,Str "image"]
+ ,Para [Str "1.5.",Space,Str "Subfigures",Space,Str "caption.",Space,Span ("",[],[]) []]
+ ,Para [Str "1.5(a).",Space,Str "Subfigure",Space,Str "a"]
+ ,Para [Str "1.5(b).",Space,Str "Subfigure",Space,Str "b"]]
+ ,Header 1 ("",[],[]) [Str "List",Space,Str "of",Space,Str "Tables"]
+ ,Div ("",["list"],[])
+ [Para [Str "3.1.",Space,Str "Table",Space,Str "example"]]
,Header 1 ("",[],[]) [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"]]]
- ,Header 1 ("sec:appendix-a.-custom-labels",[],[("label","AppA")]) [Str "Appendix",Space,Str "A.",Space,Str "Custom",Space,Str "labels"]
- ,Header 2 ("sec:custlabs",[],[("label","CustLab")]) [Str "This",Space,Str "section",Space,Str "will",Space,Str "have",Space,Str "custom",Space,Str "label"]]
+ ,Div ("",["list"],[])
+ [Para [Str "4.1.1.",Space,Str "Listing",Space,Str "caption"]
+ ,Para [Str "4.2.1.",Space,Str "Listing",Space,Str "caption"]
+ ,Para [Str "4.3.1.",Space,Str "Listing",Space,Str "caption"]]
+ ,Header 1 ("sec:custom-labels",[],[("label","A"),("title","Appendix")]) [Str "Appendix",Space,Str "A.",Space,Str "Custom",Space,Str "labels"]
+ ,Header 2 ("sec:custlabs",[],[("label","I")]) [Str "Section",Space,Str "A.I.",Space,Str "This",Space,Str "section",Space,Str "will",Space,Str "have",Space,Str "custom",Space,Str "label"]]
diff --git a/test/m2m/capitalization/expect.md b/test/m2m/capitalization/expect.md
new file mode 100644
index 00000000..b223145e
--- /dev/null
+++ b/test/m2m/capitalization/expect.md
@@ -0,0 +1,19 @@
+[$$eqn\qquad(1)$$]{#eq:1}
+
+![Figure 1: Image](img.png){#fig:1}
+
+::: {#tbl:1}
+ a b
+ --- ---
+ c d
+
+ : Table 1: Table
+:::
+
+eq. 1, Eq. 1, fig. 1, Fig. 1, tbl. 1, Tbl. 1
+
+eq. 1, Eq. 1, fig. 1, Fig. 1, tbl. 1, Tbl. 1
+
+eqs. 1, figs. 1, tbls. 1
+
+Eqs. 1, Figs. 1, Tbls. 1
diff --git a/test/m2m/capitalization/input.md b/test/m2m/capitalization/input.md
new file mode 100644
index 00000000..1ac6ea1a
--- /dev/null
+++ b/test/m2m/capitalization/input.md
@@ -0,0 +1,25 @@
+---
+prefixes:
+ eq:
+ ref:
+ - eq.
+ - eqs.
+---
+
+$$eqn$${#eq:1}
+
+![Image](img.png){#fig:1}
+
+| a | b |
+|:--|:--|
+| c | d |
+
+: Table {#tbl:1}
+
+@eq:1, @Eq:1, @fig:1, @Fig:1, @tbl:1, @Tbl:1
+
+[@eq:1], [@Eq:1], [@fig:1], [@Fig:1], [@tbl:1], [@Tbl:1]
+
+[@eq:1; @Eq:1; @fig:1; @Fig:1; @tbl:1; @Tbl:1]
+
+[@Eq:1; @eq:1; @Fig:1; @fig:1; @Tbl:1; @tbl:1]
diff --git a/test/m2m/chapDelim/expect.md b/test/m2m/chapDelim/expect.md
index 8d4367b3..2445e73b 100644
--- a/test/m2m/chapDelim/expect.md
+++ b/test/m2m/chapDelim/expect.md
@@ -6,4 +6,4 @@
# 2 Section {#sec:section-1}
-### 2delim1delim1 Subsubsection {#sec:subsubsection-1}
+### 2delim1 Subsubsection {#sec:subsubsection-1}
diff --git a/test/m2m/chapDelim/expect.tex b/test/m2m/chapDelim/expect.tex
deleted file mode 100644
index b815448b..00000000
--- a/test/m2m/chapDelim/expect.tex
+++ /dev/null
@@ -1,14 +0,0 @@
-\hypertarget{sec:section}{%
-\section{1 Section}\label{sec:section}}
-
-\hypertarget{sec:subsection}{%
-\subsection{1delim1 Subsection}\label{sec:subsection}}
-
-\hypertarget{sec:subsubsection}{%
-\subsubsection{1delim1delim1 Subsubsection}\label{sec:subsubsection}}
-
-\hypertarget{sec:section-1}{%
-\section{2 Section}\label{sec:section-1}}
-
-\hypertarget{sec:subsubsection-1}{%
-\subsubsection{2delim1delim1 Subsubsection}\label{sec:subsubsection-1}}
diff --git a/test/m2m/chapDelim/input.md b/test/m2m/chapDelim/input.md
index 6ba1e39b..c6ecbe67 100644
--- a/test/m2m/chapDelim/input.md
+++ b/test/m2m/chapDelim/input.md
@@ -1,8 +1,8 @@
---
-chapDelim: "delim"
-numberSections: true
-sectionsDepth: -1
-autoSectionLabels: true
+defaultOption:
+- numberSections
+adjustSectionIdentifiers: true
+chapDelim: delim
...
# Section
diff --git a/test/m2m/custom-prefixes/expect.md b/test/m2m/custom-prefixes/expect.md
new file mode 100644
index 00000000..39407cb2
--- /dev/null
+++ b/test/m2m/custom-prefixes/expect.md
@@ -0,0 +1,11 @@
+::: {#dfn:ring}
+A *ring* is a triple $(R,+,*)$ satisfying:
+
+1. [1: $+$ is an abelian group]{#cl:addgp}
+2. [2: $*$ is a monoid]{#cl:multmon}
+3. [3: $*$ distributes over $+$]{#cl:distrib}
+
+Definition 1:
+:::
+
+cl. 1, cl. 3, dfn. 1
diff --git a/test/m2m/custom-prefixes/input.md b/test/m2m/custom-prefixes/input.md
new file mode 100644
index 00000000..5d80ab8f
--- /dev/null
+++ b/test/m2m/custom-prefixes/input.md
@@ -0,0 +1,19 @@
+---
+prefixes:
+ dfn:
+ ref: ["dfn.", "dfns."]
+ title: "Definition"
+ cl:
+ ref: ["cl.", "cls."]
+ scope: "dfn"
+...
+
+
+A _ring_ is a triple $(R,+,*)$ satisfying:
+
+#. [$+$ is an abelian group]{#cl:addgp}
+#. [$*$ is a monoid]{#cl:multmon}
+#. [$*$ distributes over $+$]{#cl:distrib}
+
+
+@cl:addgp, @cl:distrib, @dfn:ring
diff --git a/test/m2m/delim/expect.md b/test/m2m/delim/expect.md
index 597d23b6..444cb491 100644
--- a/test/m2m/delim/expect.md
+++ b/test/m2m/delim/expect.md
@@ -34,7 +34,7 @@ Or in groups eqns. 1ref2last4
Groups will be compacted eqns. 1range4
-Unknown references will print labels eqns. **¿eq:none?**ref1ref3last4
+Unknown references will print labels eq. 1, [@eq:none], eqns. 3pair4
Reference prefix will override default prefix Equation 1, eqns. 3pair4
diff --git a/test/m2m/delim/expect.tex b/test/m2m/delim/expect.tex
deleted file mode 100644
index 50f9eeb8..00000000
--- a/test/m2m/delim/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-This is a test file with some referenced equations, line \[ this \]
-
-Some equations might be inside of text, \[ for example \] this one.
-
-Some equations might be on start of paragraphs:
-
-\[ start \] of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\[ separate \]
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
-
-Unknown references will print labels
-eqns.~\ref{eq:0}, \ref{eq:none}, \ref{eq:3}, \ref{eq:2}
-
-Reference prefix will override default prefix Equation \ref{eq:0},
-eqns.~\ref{eq:3}, \ref{eq:2}
-
-References with \texttt{-} prepended won't have prefix at all:
-\ref{eq:0}, \ref{eq:1}, eqns.~\ref{eq:2}, \ref{eq:3}
-
-References with suffix will have suffix printed after index
-(configurable): eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:2}
diff --git a/test/m2m/emptyChapterLabels/expect.md b/test/m2m/emptyChapterLabels/expect.md
index 663ab382..aaefd8b0 100644
--- a/test/m2m/emptyChapterLabels/expect.md
+++ b/test/m2m/emptyChapterLabels/expect.md
@@ -2,13 +2,13 @@
## 1 Subsection {#sec:subsection label=""}
-![Figure 1: Figure1](./image.png){#fig:figure1}
+![Figure 1: Figure1](./image.png){#fig:figure1}
### 1.1 Subsubsection {#sec:subsubsection}
# 2 Section {#sec:section-1}
-### 2.1.1 Subsubsection {#sec:subsubsection-1}
+### 2.1 Subsubsection {#sec:subsubsection-1}
sec. 1.1
diff --git a/test/m2m/emptyChapterLabels/expect.tex b/test/m2m/emptyChapterLabels/expect.tex
deleted file mode 100644
index 1248bcf5..00000000
--- a/test/m2m/emptyChapterLabels/expect.tex
+++ /dev/null
@@ -1,26 +0,0 @@
-\hypertarget{sec:section}{%
-\section{1 Section}\label{sec:section}}
-
-\hypertarget{sec:subsection}{%
-\subsection{1 Subsection}\label{sec:subsection}}
-
-\begin{figure}
-\hypertarget{fig:figure1}{%
-\centering
-\includegraphics{./image.png}
-\caption{Figure1}\label{fig:figure1}
-}
-\end{figure}
-
-\hypertarget{sec:subsubsection}{%
-\subsubsection{1.1 Subsubsection}\label{sec:subsubsection}}
-
-\hypertarget{sec:section-1}{%
-\section{2 Section}\label{sec:section-1}}
-
-\hypertarget{sec:subsubsection-1}{%
-\subsubsection{2.1.1 Subsubsection}\label{sec:subsubsection-1}}
-
-sec.~\ref{sec:subsubsection}
-
-fig.~\ref{fig:figure1}
diff --git a/test/m2m/emptyChapterLabels/input.md b/test/m2m/emptyChapterLabels/input.md
index dc090c0f..a3cbaa99 100644
--- a/test/m2m/emptyChapterLabels/input.md
+++ b/test/m2m/emptyChapterLabels/input.md
@@ -1,7 +1,7 @@
---
-numberSections: true
-sectionsDepth: -1
-autoSectionLabels: true
+defaultOption:
+- numberSections
+adjustSectionIdentifiers: true
...
# Section
diff --git a/test/m2m/equations-auto/expect.tex b/test/m2m/equations-auto/expect.tex
deleted file mode 100644
index c47f7b33..00000000
--- a/test/m2m/equations-auto/expect.tex
+++ /dev/null
@@ -1,41 +0,0 @@
-This is a test file with some referenced equations, line
-\begin{equation}{ this }\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}{ for example }\end{equation} this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}{ start }\end{equation} of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}{ separate }\end{equation}
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
diff --git a/test/m2m/equations-auto/input.md b/test/m2m/equations-auto/input.md
index dc9cd6e9..302c77ce 100644
--- a/test/m2m/equations-auto/input.md
+++ b/test/m2m/equations-auto/input.md
@@ -1,5 +1,5 @@
---
-autoEqnLabels: true
+autoEqnLabels: eq
...
This is a test file with some referenced equations, line $$ this $$
diff --git a/test/m2m/equations-tables-auto/expect.md b/test/m2m/equations-tables-auto/expect.md
deleted file mode 100644
index 2144a630..00000000
--- a/test/m2m/equations-tables-auto/expect.md
+++ /dev/null
@@ -1,97 +0,0 @@
-This is a test file with some referenced equations, line
-
-
-
- --------------------------------------------------------------- ---------
- $$ this $$ $$(1)$$
-
- --------------------------------------------------------------- ---------
-
-
-
-Some equations might be inside of text,
-
-
-
- --------------------------------------------------------------- ---------
- $$ for example $$ $$(2)$$
-
- --------------------------------------------------------------- ---------
-
-
-
-this one.
-
-Some equations might be on start of paragraphs:
-
-
-
- --------------------------------------------------------------- ---------
- $$ start $$ $$(3)$$
-
- --------------------------------------------------------------- ---------
-
-
-
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-
-
- --------------------------------------------------------------- ---------
- $$ separate $$ $$(4)$$
-
- --------------------------------------------------------------- ---------
-
-
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-
-::: {#eq:0}
- --------------------------------------------------------------- ---------
- $$ this $$ $$(5)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-Some equations might be inside of text,
-
-::: {#eq:1}
- --------------------------------------------------------------- ---------
- $$ for example $$ $$(6)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-this one.
-
-Some equations might be on start of paragraphs:
-
-::: {#eq:2}
- --------------------------------------------------------------- ---------
- $$ start $$ $$(7)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-::: {#eq:3}
- --------------------------------------------------------------- ---------
- $$ separate $$ $$(8)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-Then they can be referenced:
-
-Individually eq. 5, eq. 6, eq. 7, eq. 8
-
-Or in groups eqns. 5, 6, 8
-
-Groups will be compacted eqns. 5-8
diff --git a/test/m2m/equations-tables-auto/expect.tex b/test/m2m/equations-tables-auto/expect.tex
deleted file mode 100644
index c47f7b33..00000000
--- a/test/m2m/equations-tables-auto/expect.tex
+++ /dev/null
@@ -1,41 +0,0 @@
-This is a test file with some referenced equations, line
-\begin{equation}{ this }\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}{ for example }\end{equation} this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}{ start }\end{equation} of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}{ separate }\end{equation}
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
diff --git a/test/m2m/equations-tables-auto/input.md b/test/m2m/equations-tables-auto/input.md
deleted file mode 100644
index 311526d7..00000000
--- a/test/m2m/equations-tables-auto/input.md
+++ /dev/null
@@ -1,38 +0,0 @@
----
-tableEqns: true
-autoEqnLabels: true
-...
-
-This is a test file with some referenced equations, line $$ this $$
-
-Some equations might be inside of text, $$ for example $$ this one.
-
-Some equations might be on start of paragraphs:
-
-$$ start $$ of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-$$ separate $$
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line $$ this $${#eq:0}
-
-Some equations might be inside of text, $$ for example $${#eq:1} this one.
-
-Some equations might be on start of paragraphs:
-
-$$ start $${#eq:2} of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-$$ separate $${#eq:3}
-
-Then they can be referenced:
-
-Individually @eq:0, @eq:1, @eq:2, @eq:3
-
-Or in groups [@eq:0; @eq:1; @eq:3]
-
-Groups will be compacted [@eq:0; @eq:1; @eq:3; @eq:2]
diff --git a/test/m2m/equations-tables/expect.md b/test/m2m/equations-tables/expect.md
deleted file mode 100644
index 16a779ec..00000000
--- a/test/m2m/equations-tables/expect.md
+++ /dev/null
@@ -1,61 +0,0 @@
-This is a test file with some referenced equations, line $$ this $$
-
-Some equations might be inside of text, $$ for example $$ this one.
-
-Some equations might be on start of paragraphs:
-
-$$ start $$ of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-$$ separate $$
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-
-::: {#eq:0}
- --------------------------------------------------------------- ---------
- $$ this $$ $$(1)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-Some equations might be inside of text,
-
-::: {#eq:1}
- --------------------------------------------------------------- ---------
- $$ for example $$ $$(2)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-this one.
-
-Some equations might be on start of paragraphs:
-
-::: {#eq:2}
- --------------------------------------------------------------- ---------
- $$ start $$ $$(3)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-::: {#eq:3}
- --------------------------------------------------------------- ---------
- $$ separate $$ $$(4)$$
-
- --------------------------------------------------------------- ---------
-:::
-
-Then they can be referenced:
-
-Individually eq. 1, eq. 2, eq. 3, eq. 4
-
-Or in groups eqns. 1, 2, 4
-
-Groups will be compacted eqns. 1-4
diff --git a/test/m2m/equations-tables/expect.tex b/test/m2m/equations-tables/expect.tex
deleted file mode 100644
index bd8cc471..00000000
--- a/test/m2m/equations-tables/expect.tex
+++ /dev/null
@@ -1,39 +0,0 @@
-This is a test file with some referenced equations, line \[ this \]
-
-Some equations might be inside of text, \[ for example \] this one.
-
-Some equations might be on start of paragraphs:
-
-\[ start \] of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\[ separate \]
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
diff --git a/test/m2m/equations-tables/input.md b/test/m2m/equations-tables/input.md
deleted file mode 100644
index f44b85a2..00000000
--- a/test/m2m/equations-tables/input.md
+++ /dev/null
@@ -1,37 +0,0 @@
----
-tableEqns: true
-...
-
-This is a test file with some referenced equations, line $$ this $$
-
-Some equations might be inside of text, $$ for example $$ this one.
-
-Some equations might be on start of paragraphs:
-
-$$ start $$ of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-$$ separate $$
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line $$ this $${#eq:0}
-
-Some equations might be inside of text, $$ for example $${#eq:1} this one.
-
-Some equations might be on start of paragraphs:
-
-$$ start $${#eq:2} of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-$$ separate $${#eq:3}
-
-Then they can be referenced:
-
-Individually @eq:0, @eq:1, @eq:2, @eq:3
-
-Or in groups [@eq:0; @eq:1; @eq:3]
-
-Groups will be compacted [@eq:0; @eq:1; @eq:3; @eq:2]
diff --git a/test/m2m/equations/expect.md b/test/m2m/equations/expect.md
index 6585dc43..190153d8 100644
--- a/test/m2m/equations/expect.md
+++ b/test/m2m/equations/expect.md
@@ -34,7 +34,7 @@ Or in groups eqns. 1, 2, 4
Groups will be compacted eqns. 1-4
-Unknown references will print labels eqns. **¿eq:none?**, 1, 3, 4
+Unknown references will print labels eq. 1, [@eq:none], eqns. 3, 4
Reference prefix will override default prefix Equation 1, eqns. 3, 4
diff --git a/test/m2m/equations/expect.tex b/test/m2m/equations/expect.tex
deleted file mode 100644
index 50f9eeb8..00000000
--- a/test/m2m/equations/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-This is a test file with some referenced equations, line \[ this \]
-
-Some equations might be inside of text, \[ for example \] this one.
-
-Some equations might be on start of paragraphs:
-
-\[ start \] of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\[ separate \]
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
-
-Unknown references will print labels
-eqns.~\ref{eq:0}, \ref{eq:none}, \ref{eq:3}, \ref{eq:2}
-
-Reference prefix will override default prefix Equation \ref{eq:0},
-eqns.~\ref{eq:3}, \ref{eq:2}
-
-References with \texttt{-} prepended won't have prefix at all:
-\ref{eq:0}, \ref{eq:1}, eqns.~\ref{eq:2}, \ref{eq:3}
-
-References with suffix will have suffix printed after index
-(configurable): eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:2}
diff --git a/test/m2m/label-precedence/expect.md b/test/m2m/label-precedence/expect.md
index f67b628e..b2e85555 100644
--- a/test/m2m/label-precedence/expect.md
+++ b/test/m2m/label-precedence/expect.md
@@ -2,13 +2,13 @@
text
-![Figure α: A figure](image.png){#fig:fig1}
+![Figure α: A figure](image.png){#fig:fig1}
## \*.A Subsection {#subsection}
other text
-![Figure +: A figure with custom label](image.png){#fig:fig2 label="+"}
+![Figure +: A figure with custom label](image.png){#fig:fig2 label="+"}
### \*.A.A Subsubsection {#subsubsection}
diff --git a/test/m2m/label-precedence/expect.tex b/test/m2m/label-precedence/expect.tex
deleted file mode 100644
index aee86c73..00000000
--- a/test/m2m/label-precedence/expect.tex
+++ /dev/null
@@ -1,30 +0,0 @@
-\hypertarget{first-section}{%
-\section{* First Section}\label{first-section}}
-
-text
-
-\begin{figure}
-\hypertarget{fig:fig1}{%
-\centering
-\includegraphics{image.png}
-\caption{A figure}\label{fig:fig1}
-}
-\end{figure}
-
-\hypertarget{subsection}{%
-\subsection{*.A Subsection}\label{subsection}}
-
-other text
-
-\begin{figure}
-\hypertarget{fig:fig2}{%
-\centering
-\includegraphics{image.png}
-\caption{A figure with custom label}\label{fig:fig2}
-}
-\end{figure}
-
-\hypertarget{subsubsection}{%
-\subsubsection{*.A.A Subsubsection}\label{subsubsection}}
-
-text text text
diff --git a/test/m2m/label-precedence/input.md b/test/m2m/label-precedence/input.md
index d292ecf3..2bd140c6 100644
--- a/test/m2m/label-precedence/input.md
+++ b/test/m2m/label-precedence/input.md
@@ -1,10 +1,14 @@
---
-numberSections: true
-sectionsDepth: -1
-secLabels: roman
-secLevelLabels:
- - alpha A
-figLabels: alpha α
+defaultOption:
+ - numberSections
+prefixes:
+ sec:
+ numbering: roman
+ captionIndexTemplate: $$s.i%.$$$$ri$$
+ sub:
+ numbering: alpha A
+ fig:
+ numbering: alpha α
---
# First Section {label="*"}
diff --git a/test/m2m/links-names/expect.md b/test/m2m/links-names/expect.md
index 5077c43b..88388a0e 100644
--- a/test/m2m/links-names/expect.md
+++ b/test/m2m/links-names/expect.md
@@ -35,8 +35,8 @@ Or in groups eqns. [1](#eq:0), [2](#eq:1), [4](#eq:3)
Groups will be compacted eqns. [1](#eq:0)-[4](#eq:3)
-Unknown references will print labels eqns. **¿eq:none?**, [1](#eq:0),
-[3](#eq:2), [4](#eq:3)
+Unknown references will print labels [eq. 1](#eq:0), [@eq:none],
+eqns. [3](#eq:2), [4](#eq:3)
Reference prefix will override default prefix [Equation 1](#eq:0),
eqns. [3](#eq:2), [4](#eq:3)
diff --git a/test/m2m/links-names/expect.tex b/test/m2m/links-names/expect.tex
deleted file mode 100644
index 50f9eeb8..00000000
--- a/test/m2m/links-names/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-This is a test file with some referenced equations, line \[ this \]
-
-Some equations might be inside of text, \[ for example \] this one.
-
-Some equations might be on start of paragraphs:
-
-\[ start \] of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\[ separate \]
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
-
-Unknown references will print labels
-eqns.~\ref{eq:0}, \ref{eq:none}, \ref{eq:3}, \ref{eq:2}
-
-Reference prefix will override default prefix Equation \ref{eq:0},
-eqns.~\ref{eq:3}, \ref{eq:2}
-
-References with \texttt{-} prepended won't have prefix at all:
-\ref{eq:0}, \ref{eq:1}, eqns.~\ref{eq:2}, \ref{eq:3}
-
-References with suffix will have suffix printed after index
-(configurable): eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:2}
diff --git a/test/m2m/links/expect.md b/test/m2m/links/expect.md
index fc9b0d1f..fe31332a 100644
--- a/test/m2m/links/expect.md
+++ b/test/m2m/links/expect.md
@@ -35,8 +35,8 @@ Or in groups eqns. [1](#eq:0), [2](#eq:1), [4](#eq:3)
Groups will be compacted eqns. [1](#eq:0)-[4](#eq:3)
-Unknown references will print labels eqns. **¿eq:none?**, [1](#eq:0),
-[3](#eq:2), [4](#eq:3)
+Unknown references will print labels eq. [1](#eq:0), [@eq:none],
+eqns. [3](#eq:2), [4](#eq:3)
Reference prefix will override default prefix Equation [1](#eq:0),
eqns. [3](#eq:2), [4](#eq:3)
diff --git a/test/m2m/links/expect.tex b/test/m2m/links/expect.tex
deleted file mode 100644
index 50f9eeb8..00000000
--- a/test/m2m/links/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-This is a test file with some referenced equations, line \[ this \]
-
-Some equations might be inside of text, \[ for example \] this one.
-
-Some equations might be on start of paragraphs:
-
-\[ start \] of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\[ separate \]
-
-Some of those can be labelled:
-
-This is a test file with some referenced equations, line
-\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation}
-
-Some equations might be inside of text,
-\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation}
-this one.
-
-Some equations might be on start of paragraphs:
-
-\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation}
-of paragraph.
-
-Other might be on separate paragraphs of their own:
-
-\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation}
-
-Then they can be referenced:
-
-Individually eq.~\ref{eq:0}, eq.~\ref{eq:1}, eq.~\ref{eq:2},
-eq.~\ref{eq:3}
-
-Or in groups eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}
-
-Groups will be compacted
-eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:3}, \ref{eq:2}
-
-Unknown references will print labels
-eqns.~\ref{eq:0}, \ref{eq:none}, \ref{eq:3}, \ref{eq:2}
-
-Reference prefix will override default prefix Equation \ref{eq:0},
-eqns.~\ref{eq:3}, \ref{eq:2}
-
-References with \texttt{-} prepended won't have prefix at all:
-\ref{eq:0}, \ref{eq:1}, eqns.~\ref{eq:2}, \ref{eq:3}
-
-References with suffix will have suffix printed after index
-(configurable): eqns.~\ref{eq:0}, \ref{eq:1}, \ref{eq:2}
diff --git a/test/m2m/list-of/expect.md b/test/m2m/list-of/expect.md
new file mode 100644
index 00000000..4597c180
--- /dev/null
+++ b/test/m2m/list-of/expect.md
@@ -0,0 +1,69 @@
+[$$eqn1\qquad(1)$$]{#eq:1} [$$eqn2\qquad(2)$$]{#eq:2}
+[$$eqn3\qquad(3)$$]{#eq:3}
+
+![Figure 1: Image 1](img.png){#fig:1}
+
+![Figure 2: Image 2](img.png){#fig:2}
+
+![Figure 3: Image 3](img.png){#fig:3}
+
+::: {#tbl:1}
+ a b
+ --- ---
+ c d
+
+ : Table 1: Table 1
+:::
+
+::: {#tbl:2}
+ a b
+ --- ---
+ c d
+
+ : Table 2: Table 2
+:::
+
+::: {#tbl:3}
+ a b
+ --- ---
+ c d
+
+ : Table 3: Table 3
+:::
+
+# List of Figures
+
+::: {.list}
+1\. Image 1
+
+2\. Image 2
+
+3\. Image 3
+:::
+
+# List of Equations
+
+::: {.list}
+1\. $$eqn1$$
+
+2\. $$eqn2$$
+
+3\. $$eqn3$$
+:::
+
+# List of Tables
+
+::: {.list}
+1\. Table 1
+
+2\. Table 2
+
+3\. Table 3
+:::
+
+```{=tex}
+\listoffigures
+```
+```{=tex}
+\listoftables
+```
diff --git a/test/m2m/list-of/input.md b/test/m2m/list-of/input.md
new file mode 100644
index 00000000..b341d4fc
--- /dev/null
+++ b/test/m2m/list-of/input.md
@@ -0,0 +1,37 @@
+$$eqn1$${#eq:1}
+$$eqn2$${#eq:2}
+$$eqn3$${#eq:3}
+
+![Image 1](img.png){#fig:1}
+
+![Image 2](img.png){#fig:2}
+
+![Image 3](img.png){#fig:3}
+
+| a | b |
+|:--|:--|
+| c | d |
+
+: Table 1 {#tbl:1}
+
+| a | b |
+|:--|:--|
+| c | d |
+
+: Table 2 {#tbl:2}
+
+| a | b |
+|:--|:--|
+| c | d |
+
+: Table 3 {#tbl:3}
+
+\listof{fig}
+
+\listof{eq}
+
+\listof{tbl}
+
+\listoffigures
+
+\listoftables
diff --git a/test/m2m/listing-captions-ids/expect.md b/test/m2m/listing-captions-ids/expect.md
index fd498753..287a2e6c 100644
--- a/test/m2m/listing-captions-ids/expect.md
+++ b/test/m2m/listing-captions-ids/expect.md
@@ -1,7 +1,7 @@
After code block
-::: {#lst:code1 .listing .haskell}
-Listing 1: Listing caption 1
+::: {#lst:code1}
+Listing 1: Listing caption 1
``` {.haskell}
main :: IO ()
@@ -9,8 +9,8 @@ main = putStrLn "Hello World!"
```
:::
-::: {#lst:code2 .listing .haskell}
-Listing 2: Listing caption 2
+::: {#lst:code2}
+Listing 2: Listing caption 2
``` {.haskell}
main :: IO ()
@@ -18,8 +18,8 @@ main = putStrLn "Hello World!"
```
:::
-::: {#lst:code3 .listing .haskell}
-Listing 3: Listing caption 3
+::: {#lst:code3}
+Listing 3: Listing caption 3
``` {.haskell}
main :: IO ()
@@ -27,8 +27,8 @@ main = putStrLn "Hello World!"
```
:::
-::: {#lst:code4 .listing .haskell}
-Listing 4: Listing caption 4
+::: {#lst:code4}
+Listing 4: Listing caption 4
``` {.haskell}
main :: IO ()
@@ -52,8 +52,8 @@ main = putStrLn "Hello World!"
Before code block
-::: {#lst:code11 .listing .haskell}
-Listing 5: Listing caption 11
+::: {#lst:code11}
+Listing 5: Listing caption 11
``` {.haskell}
main :: IO ()
@@ -61,8 +61,8 @@ main = putStrLn "Hello World!"
```
:::
-::: {#lst:code12 .listing .haskell}
-Listing 6: Listing caption 12
+::: {#lst:code12}
+Listing 6: Listing caption 12
``` {.haskell}
main :: IO ()
@@ -70,8 +70,8 @@ main = putStrLn "Hello World!"
```
:::
-::: {#lst:code13 .listing .haskell}
-Listing 7: Listing caption 13
+::: {#lst:code13}
+Listing 7: Listing caption 13
``` {.haskell}
main :: IO ()
@@ -79,8 +79,8 @@ main = putStrLn "Hello World!"
```
:::
-::: {#lst:code14 .listing .haskell}
-Listing 8: Listing caption 14
+::: {#lst:code14}
+Listing 8: Listing caption 14
``` {.haskell}
main :: IO ()
diff --git a/test/m2m/listing-captions-ids/expect.tex b/test/m2m/listing-captions-ids/expect.tex
deleted file mode 100644
index dab5aa63..00000000
--- a/test/m2m/listing-captions-ids/expect.tex
+++ /dev/null
@@ -1,161 +0,0 @@
-After code block
-
-\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{Shaded}
-\begin{Highlighting}[]
-\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}
-\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}
-\end{Highlighting}
-\end{Shaded}
-
-: Listing caption 5 (invalid)
-
-\begin{Shaded}
-\begin{Highlighting}[]
-\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}
-\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}
-\end{Highlighting}
-\end{Shaded}
-
-: Listing caption 6 (invalid)
-
-Before code block
-
-\begin{codelisting}
-
-\caption{Listing caption 11}
-
-\hypertarget{lst:code11}{%
-\label{lst:code11}}%
-\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 12}
-
-\hypertarget{lst:code12}{%
-\label{lst:code12}}%
-\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 13}
-
-\hypertarget{lst:code13}{%
-\label{lst:code13}}%
-\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 14}
-
-\hypertarget{lst:code14}{%
-\label{lst:code14}}%
-\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}
-
-: Listing caption 15 (invalid)
-
-\begin{Shaded}
-\begin{Highlighting}[]
-\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}
-\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}
-\end{Highlighting}
-\end{Shaded}
-
-: Listing caption 16 (invalid)
-
-\begin{Shaded}
-\begin{Highlighting}[]
-\OtherTok{main ::} \DataTypeTok{IO}\NormalTok{ ()}
-\NormalTok{main }\OtherTok{=} \FunctionTok{putStrLn} \StringTok{"Hello World!"}
-\end{Highlighting}
-\end{Shaded}
diff --git a/test/m2m/listings-code-block-caption-278/expect.md b/test/m2m/listings-code-block-caption-278/expect.md
index 21d6f2c0..81d293bc 100644
--- a/test/m2m/listings-code-block-caption-278/expect.md
+++ b/test/m2m/listings-code-block-caption-278/expect.md
@@ -1,5 +1,5 @@
This is \#278 regression test
-::: {#lst:some_listing .listing}
-Listing 1: some_listing
+::: {#lst:some_listing}
+Listing 1: some_listing
:::
diff --git a/test/m2m/listings-code-block-caption-278/expect.tex b/test/m2m/listings-code-block-caption-278/expect.tex
deleted file mode 100644
index 956e5e5e..00000000
--- a/test/m2m/listings-code-block-caption-278/expect.tex
+++ /dev/null
@@ -1,4 +0,0 @@
-This is \#278 regression test
-
-\begin{lstlisting}[caption={some\_listing}, label=lst:some_listing]
-\end{lstlisting}
diff --git a/test/m2m/multiple-eqn-same-para/expect.tex b/test/m2m/multiple-eqn-same-para/expect.tex
deleted file mode 100644
index 7d91119d..00000000
--- a/test/m2m/multiple-eqn-same-para/expect.tex
+++ /dev/null
@@ -1,5 +0,0 @@
-Simple test
-\begin{equation}\protect\hypertarget{eq:1}{}{x=y}\label{eq:1}\end{equation}
-\begin{equation}\protect\hypertarget{eq:2}{}{x=y}\label{eq:2}\end{equation}
-
-eqns.~\ref{eq:1}, \ref{eq:2}
diff --git a/test/m2m/numbering-parts/expect.md b/test/m2m/numbering-parts/expect.md
new file mode 100644
index 00000000..33412ae6
--- /dev/null
+++ b/test/m2m/numbering-parts/expect.md
@@ -0,0 +1,27 @@
+# I. First part {#prt:prt1}
+
+## 1. First chapter {#sec:cha1}
+
+## 2. Second chapter {#sec:cha2}
+
+### 2.1. A section {#sec:sec21}
+
+### 2.2. Another section {#sec:sec22}
+
+# II. Second part {#prt:prt2}
+
+## 3. Third chapter {#sec:cha3}
+
+prt. I;
+
+chp. 1;
+
+chp. 2;
+
+sec. 2.1;
+
+sec. 2.2;
+
+prt. II;
+
+chp. 3;
diff --git a/test/m2m/numbering-parts/input.md b/test/m2m/numbering-parts/input.md
new file mode 100644
index 00000000..02191d13
--- /dev/null
+++ b/test/m2m/numbering-parts/input.md
@@ -0,0 +1,45 @@
+---
+prefixes:
+ prt:
+ from: sec
+ title: Part
+ ref: ["prt.", "prts."]
+ numbering: roman
+ sec:
+ captionTemplate: '$$i$$$$titleDelim$$ $$t$$' # show part/etc numbers
+ titleDelim: '.'
+ numbering: arabic
+ title: Chapter
+ ref: ["chp.", "chps."]
+ sub:
+ # sub-sections can override any settings from parent
+ # Here we want to have sections scoped to chapters, so
+ scope: sec
+ title: Section
+ ref: ["sec.", "secs."]
+ # We also want to show parent scope number in reference and title
+ captionIndexTemplate: '$$s.i$$.$$ri$$'
+ referenceIndexTemplate: '$$s.i$$.$$ri$$'
+...
+
+# First part {#prt:prt1}
+## First chapter {#sec:cha1}
+## Second chapter {#sec:cha2}
+### A section {#sec:sec21}
+### Another section {#sec:sec22}
+# Second part {#prt:prt2}
+## Third chapter {#sec:cha3}
+
+@prt:prt1;
+
+@sec:cha1;
+
+@sec:cha2;
+
+@sec:sec21;
+
+@sec:sec22;
+
+@prt:prt2;
+
+@sec:cha3;
diff --git a/test/m2m/ref-attrs/expect.md b/test/m2m/ref-attrs/expect.md
new file mode 100644
index 00000000..d94e3dd7
--- /dev/null
+++ b/test/m2m/ref-attrs/expect.md
@@ -0,0 +1,31 @@
+![Test1 1: Image 1](img.png){#fig:1 ref="img." ref="imgs."
+title="Test1"}
+
+![Test2 2: Image 2](img.png){#fig:2 ref="img." ref="imgs."
+title="Test2"}
+
+![Figure 3: Image 3](img.png){#fig:3}
+
+This should have custom prefix: img. 1
+
+This should have custom prefix: img. 2
+
+This should have normal prefix: fig. 3
+
+This should have custom prefix: imgs. 1, 2
+
+This should have custom prefix: imgs. 1-3
+
+This should have normal prefix: figs. 1-3
+
+This should have custom prefix (capitalized): Img. 1
+
+This should have custom prefix (capitalized): Img. 2
+
+This should have normal prefix (capitalized): Fig. 3
+
+This should have custom prefix (capitalized): Imgs. 1, 2
+
+This should have custom prefix (capitalized): Imgs. 1-3
+
+This should have normal prefix (capitalized): Figs. 1-3
diff --git a/test/m2m/ref-attrs/input.md b/test/m2m/ref-attrs/input.md
new file mode 100644
index 00000000..383aaa50
--- /dev/null
+++ b/test/m2m/ref-attrs/input.md
@@ -0,0 +1,29 @@
+![Image 1](img.png){#fig:1 ref="img." ref="imgs." title="Test1"}
+
+![Image 2](img.png){#fig:2 ref="img." ref="imgs." title="Test2"}
+
+![Image 3](img.png){#fig:3}
+
+This should have custom prefix: @fig:1
+
+This should have custom prefix: @fig:2
+
+This should have normal prefix: @fig:3
+
+This should have custom prefix: [@fig:1; @fig:2]
+
+This should have custom prefix: [@fig:1; @fig:2; @fig:3]
+
+This should have normal prefix: [@fig:3; @fig:1; @fig:2]
+
+This should have custom prefix (capitalized): @Fig:1
+
+This should have custom prefix (capitalized): @Fig:2
+
+This should have normal prefix (capitalized): @Fig:3
+
+This should have custom prefix (capitalized): [@Fig:1; @Fig:2]
+
+This should have custom prefix (capitalized): [@Fig:1; @Fig:2; @Fig:3]
+
+This should have normal prefix (capitalized): [@Fig:3; @Fig:1; @Fig:2]
diff --git a/test/m2m/regresssion-219/expect.md b/test/m2m/regresssion-219/expect.md
new file mode 100644
index 00000000..cef12d79
--- /dev/null
+++ b/test/m2m/regresssion-219/expect.md
@@ -0,0 +1,2 @@
+A citation starting with "fig", like @Figueroa2012-tu should not be
+interpreted as a reference.
diff --git a/test/m2m/regresssion-219/input.md b/test/m2m/regresssion-219/input.md
new file mode 100644
index 00000000..cef12d79
--- /dev/null
+++ b/test/m2m/regresssion-219/input.md
@@ -0,0 +1,2 @@
+A citation starting with "fig", like @Figueroa2012-tu should not be
+interpreted as a reference.
diff --git a/test/m2m/scoping/expect.md b/test/m2m/scoping/expect.md
new file mode 100644
index 00000000..9fa7be83
--- /dev/null
+++ b/test/m2m/scoping/expect.md
@@ -0,0 +1,44 @@
+# Chapter 1. Section 1 {#sec:1}
+
+## Section 1.1. Section 1.1 {#sec:11}
+
+::: {#dfn:group}
+A *group* is a pair $(R,*)$ satisfying:
+
+1. [1: $*$ is a monoid]{#cl:grpmul}
+
+Definition 1:
+:::
+
+# Chapter 2. Section 2 {#sec:2}
+
+## Section 2.1. Section 2.1 {#sec:21}
+
+### Paragraph 2.1.1. Section 2.1.1 {#sec:211}
+
+### Paragraph 2.1.2. Section 2.1.2 {#sec:212}
+
+::: {#dfn:ring}
+A *ring* is a triple $(R,+,*)$ satisfying:
+
+1. [1: $+$ is an abelian group]{#cl:addgp}
+2. [2: $*$ is a monoid]{#cl:multmon}
+3. [3: $*$ distributes over $+$]{#cl:distrib}
+
+Definition 1:
+:::
+
+# Chapter 3. Section 3 {#section-3}
+
+- chp. 1
+- sec. 1.1 (chp. 1)
+- dfn. 1 (sec. 1.1 (chp. 1))
+- cl. 1 (dfn. 1 (sec. 1.1 (chp. 1)))
+
+------------------------------------------------------------------------
+
+- chp. 2
+- dfn. 1 (par. 2.1.2 (sec. 2.1 (chp. 2)))
+- cl. 1 (dfn. 1 (par. 2.1.2 (sec. 2.1 (chp. 2))))
+- Cl. 2 (dfn. 1 (par. 2.1.2 (sec. 2.1 (chp. 2))))
+- Cl. 3 (dfn. 1 (par. 2.1.2 (sec. 2.1 (chp. 2))))
diff --git a/test/m2m/scoping/input.md b/test/m2m/scoping/input.md
new file mode 100644
index 00000000..ac6f819e
--- /dev/null
+++ b/test/m2m/scoping/input.md
@@ -0,0 +1,68 @@
+---
+prefixes:
+ dfn:
+ ref: ["dfn.", "dfns."]
+ title: "Definition"
+ scope: "sec"
+ referenceIndexTemplate: "$$i$$$$s.ref# (%)$$"
+ cl:
+ ref: ["cl.", "cls."]
+ scope: "dfn"
+ referenceIndexTemplate: "$$i$$$$s.ref# (%)$$"
+ sec:
+ captionTemplate: '$$title% $$$$i$$$$titleDelim$$ $$t$$'
+ captionIndexTemplate: '$$s.i%.$$$$ri$$'
+ referenceIndexTemplate: '$$i$$$$s.ref# (%)$$'
+ scope: sec
+ titleDelim: '.'
+ title: Chapter
+ ref: ["chp.", "chps."]
+ sub:
+ title: Section
+ ref: ["sec.", "secs."]
+ sub:
+ title: Paragraph
+ ref: ["par.", "pars."]
+chapters: false
+...
+
+# Section 1 {#sec:1}
+
+## Section 1.1 {#sec:11}
+
+
+A _group_ is a pair $(R,*)$ satisfying:
+
+#. [$*$ is a monoid]{#cl:grpmul}
+
+
+# Section 2 {#sec:2}
+
+## Section 2.1 {#sec:21}
+
+### Section 2.1.1 {#sec:211}
+
+### Section 2.1.2 {#sec:212}
+
+
+A _ring_ is a triple $(R,+,*)$ satisfying:
+
+#. [$+$ is an abelian group]{#cl:addgp}
+#. [$*$ is a monoid]{#cl:multmon}
+#. [$*$ distributes over $+$]{#cl:distrib}
+
+
+# Section 3
+
+- @sec:1
+- @sec:11
+- @dfn:group
+- @cl:grpmul
+
+---
+
+- @sec:2
+- @dfn:ring
+- @cl:addgp
+- @Cl:multmon
+- @Cl:distrib
diff --git a/test/m2m/secLabels/expect.md b/test/m2m/secLabels/expect.md
index 19a6c533..31a7a8eb 100644
--- a/test/m2m/secLabels/expect.md
+++ b/test/m2m/secLabels/expect.md
@@ -2,7 +2,7 @@
## a.a Second Level Section {#second-level-section}
-![Figure a: my figure](myfig.png){#fig:myfig}
+![Figure a: my figure](myfig.png){#fig:myfig}
## a.b Other Second Level Section {#other-second-level-section}
@@ -12,5 +12,5 @@
1 2 3
4 5 6
- : Table I: My table
+ : Table I: My table
:::
diff --git a/test/m2m/secLabels/expect.tex b/test/m2m/secLabels/expect.tex
deleted file mode 100644
index 63536043..00000000
--- a/test/m2m/secLabels/expect.tex
+++ /dev/null
@@ -1,33 +0,0 @@
-\hypertarget{first-level-section}{%
-\section{a First Level Section}\label{first-level-section}}
-
-\hypertarget{second-level-section}{%
-\subsection{a.a Second Level Section}\label{second-level-section}}
-
-\begin{figure}
-\hypertarget{fig:myfig}{%
-\centering
-\includegraphics{myfig.png}
-\caption{my figure}\label{fig:myfig}
-}
-\end{figure}
-
-\hypertarget{other-second-level-section}{%
-\subsection{a.b Other Second Level
-Section}\label{other-second-level-section}}
-
-\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}
diff --git a/test/m2m/secLabels/input.md b/test/m2m/secLabels/input.md
index c7e71ca0..80fd4230 100644
--- a/test/m2m/secLabels/input.md
+++ b/test/m2m/secLabels/input.md
@@ -1,9 +1,14 @@
---
-numberSections: true
-sectionsDepth: -1
-secLabels: alpha a
-figLabels: alpha a
-tblLabels: roman
+defaultOption:
+ - numberSections
+prefixes:
+ sec:
+ numbering: alpha a
+ captionIndexTemplate: $$s.i%.$$$$ri$$
+ fig:
+ numbering: alpha a
+ tbl:
+ numbering: roman
---
# First Level Section
diff --git a/test/m2m/secLevelLabels/expect.md b/test/m2m/secLevelLabels/expect.md
index 5b8a7de5..43d3c0ee 100644
--- a/test/m2m/secLevelLabels/expect.md
+++ b/test/m2m/secLevelLabels/expect.md
@@ -1,11 +1,11 @@
-# A. First Section {#first-section}
+# First Section
text
-## A.1) Subsection {#subsection}
+## Subsection
other text
-### A.1.i Subsubsection {#subsubsection}
+### Subsubsection
text text text
diff --git a/test/m2m/secLevelLabels/expect.tex b/test/m2m/secLevelLabels/expect.tex
deleted file mode 100644
index b1ceae12..00000000
--- a/test/m2m/secLevelLabels/expect.tex
+++ /dev/null
@@ -1,14 +0,0 @@
-\hypertarget{first-section}{%
-\section{A. First Section}\label{first-section}}
-
-text
-
-\hypertarget{subsection}{%
-\subsection{A.1) Subsection}\label{subsection}}
-
-other text
-
-\hypertarget{subsubsection}{%
-\subsubsection{A.1.i Subsubsection}\label{subsubsection}}
-
-text text text
diff --git a/test/m2m/section-template/expect.tex b/test/m2m/section-template/expect.tex
deleted file mode 100644
index 101c9178..00000000
--- a/test/m2m/section-template/expect.tex
+++ /dev/null
@@ -1,19 +0,0 @@
-\hypertarget{first-level-section}{%
-\section{Chapter 1. First Level Section}\label{first-level-section}}
-
-\hypertarget{second-level-section}{%
-\subsection{Section 1.1. Second Level
-Section}\label{second-level-section}}
-
-\hypertarget{thrid-level-section}{%
-\subsubsection{Paragraph 1.1.1. Thrid Level
-Section}\label{thrid-level-section}}
-
-\hypertarget{fourth-level-section}{%
-\paragraph{1.1.1.1. Fourth Level Section}\label{fourth-level-section}}
-
-\hypertarget{fifth-level-section}{%
-\subparagraph{1.1.1.1.1. Fifth Level
-Section}\label{fifth-level-section}}
-
-1.1.1.1.1.1. Sixth Level Section
diff --git a/test/m2m/section-template/input.md b/test/m2m/section-template/input.md
index 4a9d6063..2fa390da 100644
--- a/test/m2m/section-template/input.md
+++ b/test/m2m/section-template/input.md
@@ -1,12 +1,14 @@
---
-secHeaderTemplate: $$secHeaderPrefix[n]$$$$i$$. $$t$$
-secHeaderPrefix:
- - "Chapter "
- - "Section "
- - "Paragraph "
- - ""
-sectionsDepth: -1
-numberSections: true
+prefixes:
+ sec:
+ captionTemplate: $$titleName[lvl]$$$$i$$. $$t$$
+ captionIndexTemplate: '$$s.i%.$$$$ri$$'
+ scope: sec
+ titleName:
+ - "Chapter "
+ - "Section "
+ - "Paragraph "
+ - ""
---
# First Level Section
diff --git a/test/m2m/setLabelAttribute/expect.md b/test/m2m/setLabelAttribute/expect.md
index 7328b745..21380107 100644
--- a/test/m2m/setLabelAttribute/expect.md
+++ b/test/m2m/setLabelAttribute/expect.md
@@ -1,23 +1,21 @@
# Section {#section label="1"}
-![Figure 1.1: Figure](./image.png){#fig:1 label="1.1"}
+![Figure 1.1: Figure](./image.png){#fig:1 label="1"}
-[$$equation\qquad(1.1)$$]{#eq:1 label="1.1"}
+[$$equation\qquad(1.1)$$]{#eq:1 label="1"}
-::: {#tbl:1 label="1.1"}
+::: {#tbl:1 label="1"}
a b
--- ---
1 2
- : Table 1.1: Table
+ : Table 1.1: Table
:::
-::: {#lst:1 .listing}
-Listing 1.1: Code Listing
+::: {#lst:1 label="1"}
+Listing 1.1: Code Listing
-``` {label="1.1"}
-code
-```
+ code
:::
-## Section {#section-1 label="1.customLabel"}
+## Section {#section-1 label="customLabel"}
diff --git a/test/m2m/setLabelAttribute/expect.tex b/test/m2m/setLabelAttribute/expect.tex
deleted file mode 100644
index a9cff37c..00000000
--- a/test/m2m/setLabelAttribute/expect.tex
+++ /dev/null
@@ -1,42 +0,0 @@
-\hypertarget{section}{%
-\section{Section}\label{section}}
-
-\begin{figure}
-\hypertarget{fig:1}{%
-\centering
-\includegraphics{./image.png}
-\caption{Figure}\label{fig:1}
-}
-\end{figure}
-
-\begin{equation}\protect\hypertarget{eq:1}{}{equation}\label{eq:1}\end{equation}
-
-\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}
-
-\begin{codelisting}
-
-\caption{Code Listing}
-
-\hypertarget{lst:1}{%
-\label{lst:1}}%
-\begin{verbatim}
-code
-\end{verbatim}
-
-\end{codelisting}
-
-\hypertarget{section-1}{%
-\subsection{Section}\label{section-1}}
diff --git a/test/m2m/setLabelAttribute/input.md b/test/m2m/setLabelAttribute/input.md
index 97bffa32..ad7804c0 100644
--- a/test/m2m/setLabelAttribute/input.md
+++ b/test/m2m/setLabelAttribute/input.md
@@ -1,7 +1,8 @@
---
+defaultOption:
+- chapters
setLabelAttribute: true
codeBlockCaptions: true
-chapters: true
...
# Section
diff --git a/test/m2m/subfigures-ccsDelim/expect.md b/test/m2m/subfigures-ccsDelim/expect.md
index f30cef33..b1844c93 100644
--- a/test/m2m/subfigures-ccsDelim/expect.md
+++ b/test/m2m/subfigures-ccsDelim/expect.md
@@ -1,20 +1,17 @@
You can define subfigures:
-::: {#fig:subfigures .subfigures}
-![a](fig1.png "fig:"){#fig:subfig1} ![b](fig2.png "fig:"){#fig:subfig2}
-![c](fig3.png "fig:")
+::: {#fig:subfigures .subcaption}
+![a](fig1.png "fig:"){#fig:subfig1}![b](fig2.png "fig:"){#fig:subfig2}![c](fig3.png "fig:")
-![d](fig4.png "fig:"){#fig:subfig4} ![e](fig5.png "fig:")
-![f](fig6.png "fig:"){#fig:subfig6}
+![d](fig4.png "fig:"){#fig:subfig4}![e](fig5.png "fig:")![f](fig6.png "fig:"){#fig:subfig6}
-![g](fig7.png "fig:"){#fig:subfig7} ![h](fig8.png "fig:")
-![i](fig9.png "fig:"){#fig:subfig9}
+![g](fig7.png "fig:"){#fig:subfig7}![h](fig8.png "fig:")![i](fig9.png "fig:"){#fig:subfig9}
-Figure 1: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---
-6; g --- 7; h --- 8; i --- 9
+Figure 1: Caption. a -- 1; b -- 2; c -- 3; d -- 4; e -- 5; f -- 6; g --
+7; h -- 8; i -- 9
:::
-::: {#fig:subfigures2 .subfigures}
+::: {#fig:subfigures2 .subcaption}
![a](fig1.png){#fig:subfig21}
![b](fig2.png){#fig:subfig22}
@@ -33,8 +30,8 @@ Figure 1: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---
![i](fig9.png){#fig:subfig29}
-Figure 2: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---
-6; g --- 7; h --- 8; i --- 9
+Figure 2: Caption. a -- 1; b -- 2; c -- 3; d -- 4; e -- 5; f -- 6; g --
+7; h -- 8; i -- 9
:::
Figures themselves can be referenced fig. 2, as well as individual
diff --git a/test/m2m/subfigures-ccsDelim/expect.tex b/test/m2m/subfigures-ccsDelim/expect.tex
deleted file mode 100644
index 9481106e..00000000
--- a/test/m2m/subfigures-ccsDelim/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-You can define subfigures:
-
-\begin{pandoccrossrefsubfigures}
-
-\subfloat[1]{\includegraphics{fig1.png}\label{fig:subfig1}}
-\subfloat[2]{\includegraphics{fig2.png}\label{fig:subfig2}}
-\subfloat[3]{\includegraphics{fig3.png}}
-
-\subfloat[4]{\includegraphics{fig4.png}\label{fig:subfig4}}
-\subfloat[5]{\includegraphics{fig5.png}}
-\subfloat[6]{\includegraphics{fig6.png}\label{fig:subfig6}}
-
-\subfloat[7]{\includegraphics{fig7.png}\label{fig:subfig7}}
-\subfloat[8]{\includegraphics{fig8.png}}
-\subfloat[9]{\includegraphics{fig9.png}\label{fig:subfig9}}
-
-\caption[{Caption}]{Caption}
-
-\label{fig:subfigures}
-
-\end{pandoccrossrefsubfigures}
-
-\begin{pandoccrossrefsubfigures}
-
-\subfloat[1]{\includegraphics{fig1.png}\label{fig:subfig21}}
-
-\subfloat[2]{\includegraphics{fig2.png}\label{fig:subfig22}}
-
-\subfloat[3]{\includegraphics{fig3.png}}
-
-\subfloat[4]{\includegraphics{fig4.png}\label{fig:subfig24}}
-
-\subfloat[5]{\includegraphics{fig5.png}}
-
-\subfloat[6]{\includegraphics{fig6.png}\label{fig:subfig26}}
-
-\subfloat[7]{\includegraphics{fig7.png}\label{fig:subfig27}}
-
-\subfloat[8]{\includegraphics{fig8.png}}
-
-\subfloat[9]{\includegraphics{fig9.png}\label{fig:subfig29}}
-
-\caption[{Caption}]{Caption}
-
-\label{fig:subfigures2}
-
-\end{pandoccrossrefsubfigures}
-
-Figures themselves can be referenced fig.~\ref{fig:subfigures2}, as well
-as individual subfigures:
-figs.~\ref{fig:subfig1}, \ref{fig:subfig2}, \ref{fig:subfig29}
diff --git a/test/m2m/subfigures-ccsDelim/input.md b/test/m2m/subfigures-ccsDelim/input.md
index c57c276f..cb6a4b80 100644
--- a/test/m2m/subfigures-ccsDelim/input.md
+++ b/test/m2m/subfigures-ccsDelim/input.md
@@ -1,6 +1,16 @@
---
-ccsDelim: "; "
-...
+autoFigLabels: fig
+prefixes:
+ fig:
+ subcaptions: true
+ subcaptionsGrid: false
+ collectedCaptionDelim: "; "
+ sub:
+ numbering: alpha a
+ referenceIndexTemplate: $$s.i$$ ($$i$$)
+ captionTemplate: $$i$$
+ scope: "fig"
+---
You can define subfigures:
@@ -17,7 +27,7 @@ You can define subfigures:
![8](fig8.png)
![9](fig9.png){#fig:subfig9}
- Caption
+ : Caption. []{}
@@ -39,7 +49,7 @@ You can define subfigures:
![9](fig9.png){#fig:subfig29}
- Caption
+ \: Caption. []{}
Figures themselves can be referenced @fig:subfigures2, as well as individual subfigures: [@fig:subfig1; @fig:subfig2; @fig:subfig29]
diff --git a/test/m2m/subfigures-grid/expect.md b/test/m2m/subfigures-grid/expect.md
index a1144029..951bab35 100644
--- a/test/m2m/subfigures-grid/expect.md
+++ b/test/m2m/subfigures-grid/expect.md
@@ -1,47 +1,95 @@
You can define subfigures:
-::: {#fig:subfigures .subfigures}
+::: {#fig:subfigures .subcaption}
+:------------------:+:------------------:+:------------------:+
+| |
|
|
+| | | |
| ![a](fig1 | ![b](fig2 | ![c](fig3. |
| .png){#fig:subfig1 | .png){#fig:subfig2 | png){width="100%"} |
| width="100%"} | width="100%"} | |
+| | |
|
+|
|
| |
+--------------------+--------------------+--------------------+
+| |
|
|
+| | | |
| ![d](fig4 | ![e](fig5. | ![f](fig6 |
| .png){#fig:subfig4 | png){width="100%"} | .png){#fig:subfig6 |
| width="100%"} | | width="100%"} |
+| |
| |
+|
| |
|
+--------------------+--------------------+--------------------+
+| |
|
|
+| | | |
| ![g](fig7 | ![h](fig8. | ![i](fig9 |
| .png){#fig:subfig7 | png){width="100%"} | .png){#fig:subfig9 |
| width="100%"} | | width="100%"} |
+| |
| |
+|
| |
|
+--------------------+--------------------+--------------------+
-Figure 1: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
-g --- 7, h --- 8, i --- 9
+Figure 1: Caption. a -- 1, b -- 2, c -- 3, d -- 4, e -- 5, f -- 6, g --
+7, h -- 8, i -- 9
:::
-::: {#fig:subfigures2 .subfigures}
+::: {#fig:subfigures2 .subcaption}
+:--------------------------------------------------------------------:+
+| |
+| |
| ![a](fig1.png){#fig:subfig21 width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![b](fig2.png){#fig:subfig22 width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![c](fig3.png){width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![d](fig4.png){#fig:subfig24 width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![e](fig5.png){width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![f](fig6.png){#fig:subfig26 width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![g](fig7.png){#fig:subfig27 width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![h](fig8.png){width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
+| |
+| |
| ![i](fig9.png){#fig:subfig29 width="100%"} |
+| |
+|
|
+----------------------------------------------------------------------+
-Figure 2: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
-g --- 7, h --- 8, i --- 9
+Figure 2: Caption. a -- 1, b -- 2, c -- 3, d -- 4, e -- 5, f -- 6, g --
+7, h -- 8, i -- 9
:::
Figures themselves can be referenced fig. 2, as well as individual
diff --git a/test/m2m/subfigures-grid/expect.tex b/test/m2m/subfigures-grid/expect.tex
deleted file mode 100644
index dab218fe..00000000
--- a/test/m2m/subfigures-grid/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-You can define subfigures:
-
-\begin{pandoccrossrefsubfigures}
-
-\subfloat[1]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig1.png}\label{fig:subfig1}}
-\subfloat[2]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig2.png}\label{fig:subfig2}}
-\subfloat[3]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig3.png}}
-
-\subfloat[4]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig4.png}\label{fig:subfig4}}
-\subfloat[5]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig5.png}}
-\subfloat[6]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig6.png}\label{fig:subfig6}}
-
-\subfloat[7]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig7.png}\label{fig:subfig7}}
-\subfloat[8]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig8.png}}
-\subfloat[9]{\includegraphics[width=0.3\textwidth,height=\textheight]{fig9.png}\label{fig:subfig9}}
-
-\caption[{Caption}]{Caption}
-
-\label{fig:subfigures}
-
-\end{pandoccrossrefsubfigures}
-
-\begin{pandoccrossrefsubfigures}
-
-\subfloat[1]{\includegraphics{fig1.png}\label{fig:subfig21}}
-
-\subfloat[2]{\includegraphics{fig2.png}\label{fig:subfig22}}
-
-\subfloat[3]{\includegraphics{fig3.png}}
-
-\subfloat[4]{\includegraphics{fig4.png}\label{fig:subfig24}}
-
-\subfloat[5]{\includegraphics{fig5.png}}
-
-\subfloat[6]{\includegraphics{fig6.png}\label{fig:subfig26}}
-
-\subfloat[7]{\includegraphics{fig7.png}\label{fig:subfig27}}
-
-\subfloat[8]{\includegraphics{fig8.png}}
-
-\subfloat[9]{\includegraphics{fig9.png}\label{fig:subfig29}}
-
-\caption[{Caption}]{Caption}
-
-\label{fig:subfigures2}
-
-\end{pandoccrossrefsubfigures}
-
-Figures themselves can be referenced fig.~\ref{fig:subfigures2}, as well
-as individual subfigures:
-figs.~\ref{fig:subfig1}, \ref{fig:subfig2}, \ref{fig:subfig29}
diff --git a/test/m2m/subfigures-grid/input.md b/test/m2m/subfigures-grid/input.md
index 09bc9939..21bf5ce1 100644
--- a/test/m2m/subfigures-grid/input.md
+++ b/test/m2m/subfigures-grid/input.md
@@ -1,6 +1,15 @@
---
-subfigGrid: true
-...
+autoFigLabels: fig
+prefixes:
+ fig:
+ subcaptions: true
+ subcaptionsGrid: true
+ sub:
+ numbering: alpha a
+ referenceIndexTemplate: $$s.i$$ ($$i$$)
+ captionTemplate: $$i$$
+ scope: "fig"
+---
You can define subfigures:
@@ -17,7 +26,7 @@ You can define subfigures:
![8](fig8.png){width=30%}
![9](fig9.png){#fig:subfig9 width=30%}
- Caption
+ : Caption. []{}
@@ -39,7 +48,7 @@ You can define subfigures:
![9](fig9.png){#fig:subfig29}
- Caption
+ \: Caption. []{}
Figures themselves can be referenced @fig:subfigures2, as well as individual subfigures: [@fig:subfig1; @fig:subfig2; @fig:subfig29]
diff --git a/test/m2m/subfigures-template-collect/expect.md b/test/m2m/subfigures-template-collect/expect.md
new file mode 100644
index 00000000..ec760644
--- /dev/null
+++ b/test/m2m/subfigures-template-collect/expect.md
@@ -0,0 +1,38 @@
+You can define subfigures:
+
+::: {#fig:subfigures .subcaption}
+![a](fig1.png "fig:"){#fig:subfig1}![b](fig2.png "fig:"){#fig:subfig2}![c](fig3.png "fig:")
+
+![d](fig4.png "fig:"){#fig:subfig4}![e](fig5.png "fig:")![f](fig6.png "fig:"){#fig:subfig6}
+
+![g](fig7.png "fig:"){#fig:subfig7}![h](fig8.png "fig:")![i](fig9.png "fig:"){#fig:subfig9}
+
+Figure 1: Caption. a -- 1, b -- 2, c -- 3, d -- 4, e -- 5, f -- 6, g --
+7, h -- 8, i -- 9
+:::
+
+::: {#fig:subfigures2 .subcaption}
+![a](fig1.png){#fig:subfig21}
+
+![b](fig2.png){#fig:subfig22}
+
+![c](fig3.png)
+
+![d](fig4.png){#fig:subfig24}
+
+![e](fig5.png)
+
+![f](fig6.png){#fig:subfig26}
+
+![g](fig7.png){#fig:subfig27}
+
+![h](fig8.png)
+
+![i](fig9.png){#fig:subfig29}
+
+Figure 2: Caption. a -- 1, b -- 2, c -- 3, d -- 4, e -- 5, f -- 6, g --
+7, h -- 8, i -- 9
+:::
+
+Figures themselves can be referenced fig. 2, as well as individual
+subfigures: figs. 1 (a), 1 (b), 2 (i)
diff --git a/test/m2m/subfigures-template-collect/input.md b/test/m2m/subfigures-template-collect/input.md
new file mode 100644
index 00000000..8548675f
--- /dev/null
+++ b/test/m2m/subfigures-template-collect/input.md
@@ -0,0 +1,55 @@
+---
+autoFigLabels: fig
+prefixes:
+ fig:
+ subcaptions: true
+ subcaptionsGrid: false
+ captionTemplate: '$$title% $$$$i$$$$titleDelim$$$$t$$. []{}'
+ sub:
+ numbering: alpha a
+ referenceIndexTemplate: $$s.i$$ ($$i$$)
+ captionTemplate: $$i$$
+ scope: "fig"
+---
+
+You can define subfigures:
+
+
+ ![1](fig1.png){#fig:subfig1}
+ ![2](fig2.png){#fig:subfig2}
+ ![3](fig3.png)
+
+ ![4](fig4.png){#fig:subfig4}
+ ![5](fig5.png)
+ ![6](fig6.png){#fig:subfig6}
+
+ ![7](fig7.png){#fig:subfig7}
+ ![8](fig8.png)
+ ![9](fig9.png){#fig:subfig9}
+
+ : Caption
+
+
+
+ ![1](fig1.png){#fig:subfig21}
+
+ ![2](fig2.png){#fig:subfig22}
+
+ ![3](fig3.png)
+
+ ![4](fig4.png){#fig:subfig24}
+
+ ![5](fig5.png)
+
+ ![6](fig6.png){#fig:subfig26}
+
+ ![7](fig7.png){#fig:subfig27}
+
+ ![8](fig8.png)
+
+ ![9](fig9.png){#fig:subfig29}
+
+ \: Caption
+
+
+Figures themselves can be referenced @fig:subfigures2, as well as individual subfigures: [@fig:subfig1; @fig:subfig2; @fig:subfig29]
diff --git a/test/m2m/subfigures/expect.md b/test/m2m/subfigures/expect.md
index 70b86f41..ec760644 100644
--- a/test/m2m/subfigures/expect.md
+++ b/test/m2m/subfigures/expect.md
@@ -1,20 +1,17 @@
You can define subfigures:
-::: {#fig:subfigures .subfigures}
-![a](fig1.png "fig:"){#fig:subfig1} ![b](fig2.png "fig:"){#fig:subfig2}
-![c](fig3.png "fig:")
+::: {#fig:subfigures .subcaption}
+![a](fig1.png "fig:"){#fig:subfig1}![b](fig2.png "fig:"){#fig:subfig2}![c](fig3.png "fig:")
-![d](fig4.png "fig:"){#fig:subfig4} ![e](fig5.png "fig:")
-![f](fig6.png "fig:"){#fig:subfig6}
+![d](fig4.png "fig:"){#fig:subfig4}![e](fig5.png "fig:")![f](fig6.png "fig:"){#fig:subfig6}
-![g](fig7.png "fig:"){#fig:subfig7} ![h](fig8.png "fig:")
-![i](fig9.png "fig:"){#fig:subfig9}
+![g](fig7.png "fig:"){#fig:subfig7}![h](fig8.png "fig:")![i](fig9.png "fig:"){#fig:subfig9}
-Figure 1: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
-g --- 7, h --- 8, i --- 9
+Figure 1: Caption. a -- 1, b -- 2, c -- 3, d -- 4, e -- 5, f -- 6, g --
+7, h -- 8, i -- 9
:::
-::: {#fig:subfigures2 .subfigures}
+::: {#fig:subfigures2 .subcaption}
![a](fig1.png){#fig:subfig21}
![b](fig2.png){#fig:subfig22}
@@ -33,8 +30,8 @@ g --- 7, h --- 8, i --- 9
![i](fig9.png){#fig:subfig29}
-Figure 2: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
-g --- 7, h --- 8, i --- 9
+Figure 2: Caption. a -- 1, b -- 2, c -- 3, d -- 4, e -- 5, f -- 6, g --
+7, h -- 8, i -- 9
:::
Figures themselves can be referenced fig. 2, as well as individual
diff --git a/test/m2m/subfigures/expect.tex b/test/m2m/subfigures/expect.tex
deleted file mode 100644
index 9481106e..00000000
--- a/test/m2m/subfigures/expect.tex
+++ /dev/null
@@ -1,51 +0,0 @@
-You can define subfigures:
-
-\begin{pandoccrossrefsubfigures}
-
-\subfloat[1]{\includegraphics{fig1.png}\label{fig:subfig1}}
-\subfloat[2]{\includegraphics{fig2.png}\label{fig:subfig2}}
-\subfloat[3]{\includegraphics{fig3.png}}
-
-\subfloat[4]{\includegraphics{fig4.png}\label{fig:subfig4}}
-\subfloat[5]{\includegraphics{fig5.png}}
-\subfloat[6]{\includegraphics{fig6.png}\label{fig:subfig6}}
-
-\subfloat[7]{\includegraphics{fig7.png}\label{fig:subfig7}}
-\subfloat[8]{\includegraphics{fig8.png}}
-\subfloat[9]{\includegraphics{fig9.png}\label{fig:subfig9}}
-
-\caption[{Caption}]{Caption}
-
-\label{fig:subfigures}
-
-\end{pandoccrossrefsubfigures}
-
-\begin{pandoccrossrefsubfigures}
-
-\subfloat[1]{\includegraphics{fig1.png}\label{fig:subfig21}}
-
-\subfloat[2]{\includegraphics{fig2.png}\label{fig:subfig22}}
-
-\subfloat[3]{\includegraphics{fig3.png}}
-
-\subfloat[4]{\includegraphics{fig4.png}\label{fig:subfig24}}
-
-\subfloat[5]{\includegraphics{fig5.png}}
-
-\subfloat[6]{\includegraphics{fig6.png}\label{fig:subfig26}}
-
-\subfloat[7]{\includegraphics{fig7.png}\label{fig:subfig27}}
-
-\subfloat[8]{\includegraphics{fig8.png}}
-
-\subfloat[9]{\includegraphics{fig9.png}\label{fig:subfig29}}
-
-\caption[{Caption}]{Caption}
-
-\label{fig:subfigures2}
-
-\end{pandoccrossrefsubfigures}
-
-Figures themselves can be referenced fig.~\ref{fig:subfigures2}, as well
-as individual subfigures:
-figs.~\ref{fig:subfig1}, \ref{fig:subfig2}, \ref{fig:subfig29}
diff --git a/test/m2m/subfigures/input.md b/test/m2m/subfigures/input.md
index 5b59461d..e87a0d64 100644
--- a/test/m2m/subfigures/input.md
+++ b/test/m2m/subfigures/input.md
@@ -1,3 +1,16 @@
+---
+autoFigLabels: fig
+prefixes:
+ fig:
+ subcaptions: true
+ subcaptionsGrid: false
+ sub:
+ numbering: alpha a
+ referenceIndexTemplate: $$s.i$$ ($$i$$)
+ captionTemplate: $$i$$
+ scope: "fig"
+---
+
You can define subfigures:
@@ -13,7 +26,7 @@ You can define subfigures:
![8](fig8.png)
![9](fig9.png){#fig:subfig9}
- Caption
+ : Caption. []{}
@@ -35,7 +48,7 @@ You can define subfigures:
![9](fig9.png){#fig:subfig29}
- Caption
+ \: Caption. []{}
Figures themselves can be referenced @fig:subfigures2, as well as individual subfigures: [@fig:subfig1; @fig:subfig2; @fig:subfig29]
diff --git a/test/m2m/template-objects/expect.md b/test/m2m/template-objects/expect.md
new file mode 100644
index 00000000..68160462
--- /dev/null
+++ b/test/m2m/template-objects/expect.md
@@ -0,0 +1,31 @@
+# Section 1 {#sec:1}
+
+## Section 1.1 {#sec:11}
+
+# Section 2 {#sec:2 type="cha"}
+
+## Section 2.1 {#sec:21}
+
+### Section 2.1.1 {#sec:211}
+
+### Section 2.1.2 {#sec:212 type="par"}
+
+# Section 3
+
+# List of Sections
+
+::: {.list}
+1\. Section 1
+
+2\. Section 1.1
+
+3\. Chapter: Section 2
+
+4\. Section 2.1
+
+5\. Section 2.1.1
+
+6\. Paragraph: Section 2.1.2
+
+7\. Section 3
+:::
diff --git a/test/m2m/template-objects/input.md b/test/m2m/template-objects/input.md
new file mode 100644
index 00000000..6eacc7ac
--- /dev/null
+++ b/test/m2m/template-objects/input.md
@@ -0,0 +1,19 @@
+---
+prefixes:
+ sec:
+ listItemTemplate: '$$idx$$$$listItemNumberDelim$$$$sectionType[type]%: $$$$t$$'
+ sectionType:
+ cha: "Chapter"
+ sec: "Section"
+ par: "Paragraph"
+...
+
+# Section 1 {#sec:1}
+## Section 1.1 {#sec:11}
+# Section 2 {#sec:2 type="cha"}
+## Section 2.1 {#sec:21}
+### Section 2.1.1 {#sec:211}
+### Section 2.1.2 {#sec:212 type="par"}
+# Section 3
+
+\listof{sec}
diff --git a/test/m2m/template-options/expect.md b/test/m2m/template-options/expect.md
new file mode 100644
index 00000000..f366d101
--- /dev/null
+++ b/test/m2m/template-options/expect.md
@@ -0,0 +1,31 @@
+# Section 1 {#sec:1}
+
+## Section 1.1 {#sec:11}
+
+# Section 2 {#sec:2 shortCaption="Sec. 2" shortCaption2="Won't actually show"}
+
+## Section 2.1 {#sec:21}
+
+### Section 2.1.1 {#sec:211}
+
+### Section 2.1.2 {#sec:212 shortCaption2="Sec. 2.1.2"}
+
+# Section 3
+
+# List of Sections
+
+::: {.list}
+1\. Section 1
+
+2\. Section 1.1
+
+3\. Sec. 2
+
+4\. Section 2.1
+
+5\. Section 2.1.1
+
+6\. Sec. 2.1.2
+
+7\. Section 3
+:::
diff --git a/test/m2m/template-options/input.md b/test/m2m/template-options/input.md
new file mode 100644
index 00000000..a5dcac21
--- /dev/null
+++ b/test/m2m/template-options/input.md
@@ -0,0 +1,15 @@
+---
+prefixes:
+ sec:
+ listItemTemplate: '$$idx$$$$listItemNumberDelim$$$$shortCaption?shortCaption2?t$$'
+...
+
+# Section 1 {#sec:1}
+## Section 1.1 {#sec:11}
+# Section 2 {#sec:2 shortCaption="Sec. 2" shortCaption2="Won't actually show"}
+## Section 2.1 {#sec:21}
+### Section 2.1.1 {#sec:211}
+### Section 2.1.2 {#sec:212 shortCaption2="Sec. 2.1.2"}
+# Section 3
+
+\listof{sec}
diff --git a/test/m2m/undefined-prefix/expect.md b/test/m2m/undefined-prefix/expect.md
new file mode 100644
index 00000000..e2b890f3
--- /dev/null
+++ b/test/m2m/undefined-prefix/expect.md
@@ -0,0 +1,2 @@
+Crossref shouldn't error out when it sees something that looks like a
+reference, but with unknown prefix, like [@nonexistent:ref]
diff --git a/test/m2m/undefined-prefix/input.md b/test/m2m/undefined-prefix/input.md
new file mode 100644
index 00000000..3e837f65
--- /dev/null
+++ b/test/m2m/undefined-prefix/input.md
@@ -0,0 +1,2 @@
+Crossref shouldn't error out when it sees something that looks like
+a reference, but with unknown prefix, like [@nonexistent:ref]
diff --git a/test/test-integrative.hs b/test/test-integrative.hs
index 9331d31d..e955c1a6 100644
--- a/test/test-integrative.hs
+++ b/test/test-integrative.hs
@@ -45,17 +45,10 @@ m2m dir
, writerHighlightStyle=Just pygments
, writerListings = dir `elem` listingsDirs }
p@(Pandoc meta _) <- runIO $ either (error . show) id <$> P.runIO (readMarkdown ro $ T.pack input)
- let actual_md = either (fail . show) T.unpack $ runPure $ writeMarkdown wo $ runCrossRef meta (Just $ Format "markdown") defaultCrossRefAction p
+ let actual_md = either (fail . show) T.unpack $ runPure $ writeMarkdown wo . evalCrossRefRes . runCrossRef (Settings meta) (Just $ Format "markdown") $ defaultCrossRefAction p
it "Markdown" $ do
zipWithM_ shouldBe (lines' actual_md) (lines' expect_md)
length' (lines' actual_md) `shouldBe` length' (lines' expect_md)
-#ifdef FLAKY
- expect_tex <- runIO $ readFile ("test" > "m2m" > dir > "expect.tex")
- let actual_tex = either (fail . show) T.unpack $ runPure $ writeLaTeX wo $ runCrossRef meta (Just $ Format "latex") defaultCrossRefAction p
- it "LaTeX" $ do
- zipWithM_ shouldBe (lines' actual_tex) (lines' expect_tex)
- length' (lines' actual_tex) `shouldBe` length' (lines' expect_tex)
-#endif
where
lines' = zip [(1 :: Int)..] . lines
length' = length . filter (not . null . snd)
@@ -78,3 +71,6 @@ flaky = [ "equations-tables"
, "subfigures-grid"
]
#endif
+
+evalCrossRefRes :: Show a => (Either a c, b) -> c
+evalCrossRefRes = either (error . show) id . fst
diff --git a/test/test-pandoc-crossref.hs b/test/test-pandoc-crossref.hs
index 109ce28e..ea1f4387 100644
--- a/test/test-pandoc-crossref.hs
+++ b/test/test-pandoc-crossref.hs
@@ -18,30 +18,36 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-}
-{-# LANGUAGE FlexibleContexts, CPP, OverloadedStrings #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE FlexibleContexts, CPP, OverloadedStrings
+ , FlexibleInstances, StandaloneDeriving #-}
import Test.Hspec
-import Text.Pandoc hiding (getDataFileName)
+import Text.Pandoc hiding (getDataFileName, Template)
import Text.Pandoc.Builder
import Control.Monad.State
import Data.List
+import Data.Maybe
import Control.Arrow
import qualified Data.Map as M
-import qualified Data.Text as T
-import qualified Data.Default as Df
import Text.Pandoc.CrossRef
import Text.Pandoc.CrossRef.Util.Options
+import Text.Pandoc.CrossRef.Util.Prefixes
import Text.Pandoc.CrossRef.Util.Util
import Text.Pandoc.CrossRef.References.Types
+import Text.Pandoc.CrossRef.Util.Template.Types
import Data.Accessor hiding ((=:))
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
import qualified Text.Pandoc.CrossRef.Util.Template as Util.Template
import qualified Text.Pandoc.CrossRef.Util.CodeBlockCaptions as Util.CodeBlockCaptions
+import qualified Data.Text as T
+#ifdef FLAKY
import qualified Native
import Paths_pandoc_crossref
+#endif
import Prelude
@@ -49,35 +55,43 @@ main :: IO ()
main = hspec $ do
describe "References.Blocks.replaceInlines" $ do
it "Labels equations" $
- testAll (equation' "a^2+b^2=c^2" "equation")
- (spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" ""),
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ testAll (plain $ equation' "a^2+b^2=c^2" "equation")
+ (plain $ spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" ""),
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels equations in the middle of text" $
- testAll (
+ testAll (plain $
text "This is an equation: "
<> equation' "a^2+b^2=c^2" "equation"
<> text " it should be labeled")
- (
+ (plain $
text "This is an equation: "
<> spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" "")
<> text " it should be labeled",
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels equations in the beginning of text" $
- testAll (
+ testAll (plain $
equation' "a^2+b^2=c^2" "equation"
<> text " it should be labeled")
- (
+ (plain $
spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" "")
<> text " it should be labeled",
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels equations in the end of text" $
- testAll (
+ testAll (plain $
text "This is an equation: "
<> equation' "a^2+b^2=c^2" "equation")
- (
+ (plain $
text "This is an equation: "
<> spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" ""),
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
-- TODO:
-- describe "References.Blocks.spanInlines"
@@ -86,62 +100,81 @@ main = hspec $ do
describe "References.Blocks.replaceBlocks" $ do
it "Labels images" $
testAll (figure "test.jpg" "" "Test figure" "figure")
- (figure "test.jpg" "" "Figure 1: Test figure" "figure",
- imgRefs =: M.fromList $ refRec' "fig:figure" 1 "Test figure")
- it "Labels subfigures" $
- testAll (
- divWith ("fig:subfigure",[],[]) (
- para (figure' "fig:" "test1.jpg" "" "Test figure 1" "figure1")
- <>para (figure' "fig:" "test2.jpg" "" "Test figure 2" "figure2")
- <>para (text "figure caption")
- ) <>
- divWith ("fig:subfigure2",[],[]) (
- para (figure' "fig:" "test21.jpg" "" "Test figure 21" "figure21")
- <>para (figure' "fig:" "test22.jpg" "" "Test figure 22" "figure22")
- <>para (text "figure caption 2")
- )
+ (figure "test.jpg" "" "Figure\160\&1: Test figure" "figure",
+ (referenceData =: M.fromList [refRec' "fig:figure" 1 "Test figure" "Figure 1: Test figure"]) .
+ (pfxCounter =: M.singleton "fig" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
)
- (
- divWith ("fig:subfigure",["subfigures"],[]) (
- para (figure' "fig:" "test1.jpg" "" "a" "figure1")
- <> para (figure' "fig:" "test2.jpg" "" "b" "figure2")
- <> para (text "Figure 1: figure caption. a — Test figure 1, b — Test figure 2")
- ) <>
- divWith ("fig:subfigure2",["subfigures"],[]) (
- para (figure' "fig:" "test21.jpg" "" "a" "figure21")
- <> para (figure' "fig:" "test22.jpg" "" "b" "figure22")
- <> para (text "Figure 2: figure caption 2. a — Test figure 21, b — Test figure 22")
- )
- , imgRefs =: M.fromList [("fig:figure1",RefRec {
- refIndex = [(1,Nothing)],
- refTitle = [Str "Test",Space,Str "figure",Space,Str "1"],
- refSubfigure = Just [(1, Just "a")]}),
- ("fig:figure2",RefRec {
- refIndex = [(1,Nothing)],
- refTitle = [Str "Test",Space,Str "figure",Space,Str "2"],
- refSubfigure = Just [(2, Just "b")]}),
- ("fig:subfigure",RefRec {
- refIndex = [(1,Nothing)],
- refTitle = [Str "figure",Space,Str "caption"],
- refSubfigure = Nothing}),
- ("fig:figure21",RefRec {
- refIndex = [(2,Nothing)],
- refTitle = [Str "Test",Space,Str "figure",Space,Str "21"],
- refSubfigure = Just [(1, Just "a")]}),
- ("fig:figure22",RefRec {
- refIndex = [(2,Nothing)],
- refTitle = [Str "Test",Space,Str "figure",Space,Str "22"],
- refSubfigure = Just [(2, Just "b")]}),
- ("fig:subfigure2",RefRec {
- refIndex = [(2,Nothing)],
- refTitle = [Str "figure",Space,Str "caption",Space,Str "2"],
- refSubfigure = Nothing})
- ]
- )
+ -- it "Labels subfigures" $
+ -- testAll (
+ -- divWith ("fig:subfigure",[],[]) (
+ -- para (figure' "fig:" "test1.jpg" [] "Test figure 1" "figure1")
+ -- <>para (figure' "fig:" "test2.jpg" [] "Test figure 2" "figure2")
+ -- <>para (text "figure caption")
+ -- ) <>
+ -- divWith ("fig:subfigure2",[],[]) (
+ -- para (figure' "fig:" "test21.jpg" [] "Test figure 21" "figure21")
+ -- <>para (figure' "fig:" "test22.jpg" [] "Test figure 22" "figure22")
+ -- <>para (text "figure caption 2")
+ -- )
+ -- )
+ -- (
+ -- divWith ("fig:subfigure",["subfigures"],[]) (
+ -- para (figure' "fig:" "test1.jpg" [] "a" "figure1")
+ -- <> para (figure' "fig:" "test2.jpg" [] "b" "figure2")
+ -- <> para (text "Figure 1: figure caption. a — Test figure 1, b — Test figure 2")
+ -- ) <>
+ -- divWith ("fig:subfigure2",["subfigures"],[]) (
+ -- para (figure' "fig:" "test21.jpg" [] "a" "figure21")
+ -- <> para (figure' "fig:" "test22.jpg" [] "b" "figure22")
+ -- <> para (text "Figure 2: figure caption 2. a — Test figure 21, b — Test figure 22")
+ -- )
+ -- , (referenceData =: M.fromList [("fig:figure1",RefRec {
+ -- refIndex = [(1,"1")],
+ -- refTitle = fromList [Str "Test",Space,Str "figure",Space,Str "1"],
+ -- refScope = Nothing,
+ -- refLabel = "fig:figure1",
+ -- refSubfigure = Just [(1, "a")]}),
+ -- ("fig:figure2",RefRec {
+ -- refIndex = [(1,"1")],
+ -- refTitle = fromList [Str "Test",Space,Str "figure",Space,Str "2"],
+ -- refScope = Nothing,
+ -- refLabel = "fig:figure2",
+ -- refSubfigure = Just [(2, "b")]}),
+ -- ("fig:subfigure",RefRec {
+ -- refIndex = [(1,"1")],
+ -- refTitle = fromList [Str "figure",Space,Str "caption"],
+ -- refScope = Nothing,
+ -- refLabel = "fig:subfigure",
+ -- refSubfigure = Nothing}),
+ -- ("fig:figure21",RefRec {
+ -- refIndex = [(2,"2")],
+ -- refTitle = fromList [Str "Test",Space,Str "figure",Space,Str "21"],
+ -- refScope = Nothing,
+ -- refLabel = "fig:figure21",
+ -- refSubfigure = Just [(1, "a")]}),
+ -- ("fig:figure22",RefRec {
+ -- refIndex = [(2,"2")],
+ -- refTitle = fromList [Str "Test",Space,Str "figure",Space,Str "22"],
+ -- refScope = Nothing,
+ -- refLabel = "fig:figure22",
+ -- refSubfigure = Just [(2, "b")]}),
+ -- ("fig:subfigure2",RefRec {
+ -- refIndex = [(2,"2")],
+ -- refTitle = fromList [Str "figure",Space,Str "caption",Space,Str "2"],
+ -- refScope = Nothing,
+ -- refLabel = "fig:subfigure2",
+ -- refSubfigure = Nothing})
+ -- ]
+ -- ) .
+ -- (pfxCounter =: M.singleton "fig" 2) .
+ -- (curChap =: M.singleton "fig" "fig:subfigure2")
+ -- )
it "Labels equations" $
testAll (equation "a^2+b^2=c^2" "equation")
(para $ spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" ""),
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels equations in the middle of text" $
testAll (para $
text "This is an equation: "
@@ -151,7 +184,9 @@ main = hspec $ do
text "This is an equation: "
<> spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" "")
<> text " it should be labeled",
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels equations in the beginning of text" $
testAll (para $
equation' "a^2+b^2=c^2" "equation"
@@ -159,7 +194,9 @@ main = hspec $ do
(para $
spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" "")
<> text " it should be labeled",
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels equations in the end of text" $
testAll (para $
text "This is an equation: "
@@ -167,84 +204,100 @@ main = hspec $ do
(para $
text "This is an equation: "
<> spanWith ("eq:equation", [], []) (equation' "a^2+b^2=c^2\\qquad(1)" ""),
- eqnRefs =: M.fromList $ refRec'' "eq:equation" 1)
+ (referenceData =: M.fromList [refRec' "eq:equation" 1 (math "a^2+b^2=c^2") "1"]) .
+ (pfxCounter =: M.singleton "eq" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels tables" $
testAll (table' "Test table" "table")
- (divWith ("tbl:table", [], []) $ table' "Table 1: Test table" "",
- tblRefs =: M.fromList $ refRec' "tbl:table" 1 "Test table")
+ (divWith ("tbl:table", [], []) $ table' "Table\160\&1: Test table" "",
+ (referenceData =: M.fromList [refRec' "tbl:table" 1 "Test table" "Table 1: Test table"]) .
+ (pfxCounter =: M.singleton "tbl" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels code blocks" $
testAll (codeBlock' "Test code block" "codeblock")
- (codeBlockDiv "Listing 1: Test code block" "codeblock",
- lstRefs =: M.fromList $ refRec' "lst:codeblock" 1 "Test code block")
+ (codeBlockDiv' "Listing\160\&1: Test code block" "codeblock",
+ (referenceData =: M.fromList [refRec' "lst:codeblock" 1 "Test code block" "Listing\160\&1: Test code block"]) .
+ (pfxCounter =: M.singleton "lst" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels code block divs" $
testAll (codeBlockDiv "Test code block" "codeblock")
- (codeBlockDiv "Listing 1: Test code block" "codeblock",
- lstRefs =: M.fromList $ refRec' "lst:codeblock" 1 "Test code block")
+ (codeBlockDiv' "Listing\160\&1: Test code block" "codeblock",
+ (referenceData =: M.fromList [refRec' "lst:codeblock" 1 "Test code block" "Listing\160\&1: Test code block"]) .
+ (pfxCounter =: M.singleton "lst" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
it "Labels sections divs" $
testAll (section "Section Header" 1 "section")
(section "Section Header" 1 "section",
- secRefs ^= M.fromList (refRec' "sec:section" 1 "Section Header")
- $ curChap =: [(1,Nothing)])
+ (referenceData ^= M.fromList [refRec' "sec:section" 1 "Section Header" ""])
+ . (pfxCounter =: M.singleton "sec" $ CounterRec {crIndex = 1, crIndexInScope = M.singleton Nothing 1})
+ )
describe "References.Refs.replaceRefs" $ do
it "References one image" $
- testRefs' "fig:" [1] [4] imgRefs "fig.\160\&4"
+ testRefs' "fig:" [1] [4] referenceData "fig.\160\&4"
it "References multiple images" $
- testRefs' "fig:" [1..3] [4..6] imgRefs "figs.\160\&4-6"
+ testRefs' "fig:" [1..3] [4..6] referenceData "figs.\160\&4-6"
it "References one equation" $
- testRefs' "eq:" [1] [4] eqnRefs "eq.\160\&4"
+ testRefs' "eq:" [1] [4] referenceData "eq.\160\&4"
it "References multiple equations" $
- testRefs' "eq:" [1..3] [4..6] eqnRefs "eqns.\160\&4-6"
+ testRefs' "eq:" [1..3] [4..6] referenceData "eqns.\160\&4-6"
it "References one table" $
- testRefs' "tbl:" [1] [4] tblRefs "tbl.\160\&4"
+ testRefs' "tbl:" [1] [4] referenceData "tbl.\160\&4"
it "References multiple tables" $
- testRefs' "tbl:" [1..3] [4..6] tblRefs "tbls.\160\&4-6"
+ testRefs' "tbl:" [1..3] [4..6] referenceData "tbls.\160\&4-6"
it "References one listing" $
- testRefs' "lst:" [1] [4] lstRefs "lst.\160\&4"
+ testRefs' "lst:" [1] [4] referenceData "lst.\160\&4"
it "References multiple listings" $
- testRefs' "lst:" [1..3] [4..6] lstRefs "lsts.\160\&4-6"
+ testRefs' "lst:" [1..3] [4..6] referenceData "lsts.\160\&4-6"
it "References one section" $
- testRefs' "sec:" [1] [4] secRefs "sec.\160\&4"
+ testRefs' "sec:" [1] [4] referenceData "sec.\160\&4"
it "References multiple sections" $
- testRefs' "sec:" [1..3] [4..6] secRefs "secs.\160\&4-6"
+ testRefs' "sec:" [1..3] [4..6] referenceData "secs.\160\&4-6"
it "Separates references to different chapter items by a comma" $
- testRefs'' "lst:" [1..6] (zip [1,1..] [4..6] <> zip [2,2..] [7..9]) lstRefs "lsts.\160\&1.4-1.6, 2.7-2.9"
+ let p = "lst:"
+ cites = citeGen p [1..6]
+ chap1 = snd $ refRec' "sec:1" 1 "Section 1" "Section 1"
+ chap2 = snd $ refRec' "sec:2" 2 "Section 2" "Section 2"
+ refs1 = M.map (\r -> r{refScope = Just chap1}) $ refGen p [1..3] [4..6]
+ refs2 = M.map (\r -> r{refScope = Just chap2}) $ refGen p [4..6] [7..9]
+ res = "lsts.\160\&4-6, 7-9"
+ in testRefs (para cites) (setVal referenceData (refs1 <> refs2) def) (para $ text res)
describe "References.Refs.replaceRefs capitalization" $ do
it "References one image" $
- testRefs' "Fig:" [1] [4] imgRefs "Fig.\160\&4"
+ testRefs' "Fig:" [1] [4] referenceData "Fig.\160\&4"
it "References multiple images" $
- testRefs' "Fig:" [1..3] [4..6] imgRefs "Figs.\160\&4-6"
+ testRefs' "Fig:" [1..3] [4..6] referenceData "Figs.\160\&4-6"
it "References one equation" $
- testRefs' "Eq:" [1] [4] eqnRefs "Eq.\160\&4"
+ testRefs' "Eq:" [1] [4] referenceData "Eq.\160\&4"
it "References multiple equations" $
- testRefs' "Eq:" [1..3] [4..6] eqnRefs "Eqns.\160\&4-6"
+ testRefs' "Eq:" [1..3] [4..6] referenceData "Eqns.\160\&4-6"
it "References one table" $
- testRefs' "Tbl:" [1] [4] tblRefs "Tbl.\160\&4"
+ testRefs' "Tbl:" [1] [4] referenceData "Tbl.\160\&4"
it "References multiple tables" $
- testRefs' "Tbl:" [1..3] [4..6] tblRefs "Tbls.\160\&4-6"
+ testRefs' "Tbl:" [1..3] [4..6] referenceData "Tbls.\160\&4-6"
it "References one listing" $
- testRefs' "Lst:" [1] [4] lstRefs "Lst.\160\&4"
+ testRefs' "Lst:" [1] [4] referenceData "Lst.\160\&4"
it "References multiple listings" $
- testRefs' "Lst:" [1..3] [4..6] lstRefs "Lsts.\160\&4-6"
+ testRefs' "Lst:" [1..3] [4..6] referenceData "Lsts.\160\&4-6"
it "References one listing" $
- testRefs' "Sec:" [1] [4] secRefs "Sec.\160\&4"
+ testRefs' "Sec:" [1] [4] referenceData "Sec.\160\&4"
it "References multiple listings" $
- testRefs' "Sec:" [1..3] [4..6] secRefs "Secs.\160\&4-6"
+ testRefs' "Sec:" [1..3] [4..6] referenceData "Secs.\160\&4-6"
describe "References.List.listOf" $ do
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]))
+ testList (rawBlock "latex" "\\listof{tbl}")
+ (referenceData =: M.fromList [let l = "tbl:" <> T.pack (show i); n = i + 3; sn = str . T.pack $ show n in refRec' l n sn ("Table " <> sn <> ": " <> sn) | i <- [1..3]])
+ (header 1 (text "List of Tables") <> divWith ("",["list"],[]) (mconcat $ map (\i -> let n = T.pack (show i) in para $ text (n <> ". " <> n) ) [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]))
+ testList (rawBlock "latex" "\\listof{fig}")
+ (referenceData =: M.fromList [let l = "fig:" <> T.pack (show i); n = i + 3; sn = str . T.pack $ show n in refRec' l n sn ("Figure " <> sn <> ": " <> sn) | i <- [1..3]])
+ (header 1 (text "List of Figures") <> divWith ("",["list"],[]) (mconcat $ map (\i -> let n = T.pack (show i) in para $ text (n <> ". " <> n) ) [4..6 :: Int]))
describe "Util.CodeBlockCaptions" $
it "Transforms table-style codeBlock captions to codeblock divs" $ do
- let t x = testCBCaptions x (codeBlockDiv' "Code Block" "cb")
+ let t x = testCBCaptions x (codeBlockDiv "Code Block" "cb")
t (codeBlockForTable "cb" <> paraText ": Code Block")
t (codeBlockForTable "cb" <> paraText "Listing: Code Block")
t (paraText ": Code Block" <> codeBlockForTable "cb")
@@ -252,9 +305,14 @@ main = hspec $ do
describe "Util.Template" $
it "Applies templates" $
- let template=Util.Template.makeTemplate defaultMeta (toList $ displayMath "figureTitle" <> displayMath "i" <> displayMath "t")
- in Util.Template.applyTemplate [Str "1"] [Str "title"] template `shouldBe`
- toList (str "Figure" <> str "1" <> str "title")
+ let template=Util.Template.makeTemplate
+ (displayMath "figureTitle" <> displayMath "i" <> displayMath "t")
+ vf "i" = Just $ MetaInlines $ toList $ text "1"
+ vf "t" = Just $ MetaInlines $ toList $ text "title"
+ vf "figureTitle" = Just $ toMetaValue $ text "Figure"
+ vf _ = Nothing
+ in Util.Template.applyTemplate template vf `shouldBe`
+ (str "Figure" <> str "1" <> str "title")
describe "Citation groups shouldn't be separated (#22 regression test)" $ do
it "Should not separate citation groups" $ do
@@ -277,99 +335,76 @@ main = hspec $ do
it "demo.md matches demo.native" $ do
demomd <- readFile =<< getDataFileName "docs/demo/demo.md"
Pandoc m b <- handleError $ runPure $ readMarkdown def {readerExtensions = pandocExtensions} $ T.pack demomd
- runCrossRef m Nothing crossRefBlocks b `shouldBe` Native.demo
-
- it "demo.md with chapters matches demo-chapters.native" $ do
- demomd <- readFile =<< getDataFileName "docs/demo/demo.md"
- Pandoc m b <- handleError $ runPure $ readMarkdown def {readerExtensions = pandocExtensions} $ T.pack demomd
- let m' = setMeta "chapters" True m
- runCrossRef m' Nothing crossRefBlocks b `shouldBe` Native.demochapters
-#endif
-
- describe "LaTeX" $ do
- let test = test' nullMeta
- infixr 5 `test`
- test' m i o = getLatex m i `shouldBe` o
- getLatex m i = either (fail . show) T.unpack (runPure $ writeLaTeX def (Pandoc m $ runCrossRef m (Just $ Format "latex") crossRefBlocks (toList i)))
-
- describe "Labels" $ do
-
- it "Section labels" $
- headerWith ("sec:section_label1", [], []) 1 (text "Section")
- <> para (citeGen "sec:section_label" [1])
- `test` "\\hypertarget{sec:section_label1}{%\n\\section{Section}\\label{sec:section_label1}}\n\nsec.~\\ref{sec:section_label1}"
-
- it "Image labels" $
- figure "img.png" "" "Title" "figure_label1"
- <> para (citeGen "fig:figure_label" [1])
- `test` "\\begin{figure}\n\\hypertarget{fig:figure_label1}{%\n\\centering\n\\includegraphics{img.png}\n\\caption{Title}\\label{fig:figure_label1}\n}\n\\end{figure}\n\nfig.~\\ref{fig:figure_label1}"
-
- it "Eqn labels" $
- equation "x^2" "some_equation1"
- <> para (citeGen "eq:some_equation" [1])
- `test` "\\begin{equation}\\protect\\hypertarget{eq:some_equation1}{}{x^2}\\label{eq:some_equation1}\\end{equation}\n\neq.~\\ref{eq:some_equation1}"
-
-#ifdef FLAKY
- it "Tbl labels" $
- table' "A table" "some_table1"
- <> para (citeGen "tbl:some_table" [1])
- `test` "\\hypertarget{tbl:some_table1}{}\n\\begin{longtable}[]{@{}@{}}\n\\caption{\\label{tbl:some_table1}A table}\\tabularnewline\n\\toprule\n\\endhead\n \\\\\n\\bottomrule\n\\end{longtable}\n\ntbl.~\\ref{tbl:some_table1}"
+ let (res, _warn) = runCrossRef (Settings m) Nothing $ crossRefBlocks b
+ res `shouldBe` Right Native.demo
#endif
- it "Code block labels" $ do
- codeBlock' "A code block" "some_codeblock1"
- <> para (citeGen "lst:some_codeblock" [1])
- `test` "\\begin{codelisting}\n\n\\caption{A code block}\n\n\\hypertarget{lst:some_codeblock1}{%\n\\label{lst:some_codeblock1}}%\n\\begin{Shaded}\n\\begin{Highlighting}[]\n\\OtherTok{main ::} \\DataTypeTok{IO}\\NormalTok{ ()}\n\\end{Highlighting}\n\\end{Shaded}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}"
- codeBlock' "A code block with under_score" "some_codeblock1"
- <> para (citeGen "lst:some_codeblock" [1])
- `test` "\\begin{codelisting}\n\n\\caption{A code block with under\\_score}\n\n\\hypertarget{lst:some_codeblock1}{%\n\\label{lst:some_codeblock1}}%\n\\begin{Shaded}\n\\begin{Highlighting}[]\n\\OtherTok{main ::} \\DataTypeTok{IO}\\NormalTok{ ()}\n\\end{Highlighting}\n\\end{Shaded}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}"
- let test1 = test' $ setMeta "codeBlockCaptions" True nullMeta
- infixr 5 `test1`
- codeBlockForTable "some_codeblock1" <> paraText ": A code block"
- <> para (citeGen "lst:some_codeblock" [1])
- `test1` "\\begin{codelisting}\n\n\\caption{A code block}\n\n\\hypertarget{lst:some_codeblock1}{%\n\\label{lst:some_codeblock1}}%\n\\begin{Shaded}\n\\begin{Highlighting}[]\n\\OtherTok{main ::} \\DataTypeTok{IO}\\NormalTok{ ()}\n\\end{Highlighting}\n\\end{Shaded}\n\n\\end{codelisting}\n\nlst.~\\ref{lst:some_codeblock1}"
-
citeGen :: T.Text -> [Int] -> Inlines
citeGen p l = cite (mconcat $ map (cit . (p<>) . T.pack . show) l) $ text $
"[" <> T.intercalate "; " (map (("@"<>) . (p<>) . T.pack . show) l) <> "]"
refGen :: T.Text -> [Int] -> [Int] -> M.Map T.Text RefRec
-refGen p l1 l2 = M.fromList $ mconcat $ zipWith refRec'' (((uncapitalizeFirst p<>) . T.pack . show) `map` l1) l2
-
-refGen' :: T.Text -> [Int] -> [(Int, Int)] -> M.Map T.Text RefRec
-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})]
+refGen p l1 l2 = M.fromList $ zipWith (\r i -> refRec' r i mempty mempty) (((uncapitalizeFirst p<>) . T.pack . show) `map` l1) l2
+
+refRec' :: T.Text -> Int -> Inlines -> Inlines -> (T.Text, RefRec)
+refRec' ref i tit cap =
+ let pfx = T.takeWhile (/=':') ref
+ pfxRec = fromJust $ M.lookup pfx defaultPrefixes
+ in ( ref
+ , RefRec
+ { refIndex=i
+ , refIxInl = str . T.pack $ show i
+ , refIxInlRaw = str . T.pack $ show i
+ , refCaption= cap
+ , refTitle=tit
+ , refScope=Nothing
+ , refLevel=0
+ , refPfx=pfx
+ , refLabel=ref
+ , refAttrs = const Nothing
+ , refPfxRec = pfxRec
+ , refCaptionPosition = Below
+ }
+ )
-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})]
+testRefs :: Blocks -> References -> Blocks -> Expectation
+testRefs bs st rbs = testState (bottomUpM References.Refs.replaceRefs) st bs (rbs, id)
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, 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)
-
-testAll :: (Eq a, Data a, Show a) => Many a -> (Many a, References) -> Expectation
-testAll = testState f def
- where f = References.Blocks.replaceAll defaultOptions
-
-testState :: (Eq s, Eq a1, Show s, Show a1, Df.Default s) =>
- ([a] -> State s [a1]) -> s -> Many a -> (Many a1, s) -> Expectation
-testState f init' arg res = runState (f $ toList arg) init' `shouldBe` first toList res
-
-testRefs :: Blocks -> References -> Blocks -> Expectation
-testRefs bs st rbs = testState (bottomUpM (References.Refs.replaceRefs defaultOptions)) st bs (rbs, st)
+testAll :: Many Block -> (Many Block, References -> References) -> Expectation
+testAll = testState References.Blocks.replaceAll def
+
+evalCrossRefM :: CrossRefM c -> c
+evalCrossRefM = evalCrossRefRes . runCrossRef (defaultMeta mempty) Nothing . CrossRef
+
+evalCrossRefRes :: (Either WSException c, b) -> c
+evalCrossRefRes = either (error . show) id . fst
+
+instance Show Prefix where
+ show _ = "Prefix{}"
+instance Show Template where
+ show _ = "Template{}"
+instance Show (T.Text -> Maybe MetaValue) where
+ show _ = "T.Text -> Maybe MetaValue"
+deriving instance Show RefRec
+deriving instance Show CaptionPosition
+deriving instance Show CounterRec
+deriving instance Eq CounterRec
+deriving instance Show References
+deriving instance Eq References
+deriving instance Eq WSException
+
+testState :: (Eq a1, Show a1) => ([a] -> WS [a1]) -> References -> Many a -> (Many a1, References -> References) -> Expectation
+testState f init' arg (r, s) = evalCrossRefM $
+ (`shouldBe` (toList r, s init')) <$> runStateT (unWS . f $ toList arg) init'
testCBCaptions :: Blocks -> Blocks -> Expectation
-testCBCaptions bs res = runState (bottomUpM (Util.CodeBlockCaptions.mkCodeBlockCaptions defaultOptions{Text.Pandoc.CrossRef.Util.Options.codeBlockCaptions=True}) (toList bs)) def `shouldBe` (toList res,def)
+testCBCaptions bs res = bottomUp (Util.CodeBlockCaptions.mkCodeBlockCaptions defaultOptions{Text.Pandoc.CrossRef.Util.Options.codeBlockCaptions=True}) (toList bs) `shouldBe` toList res
-testList :: Blocks -> References -> Blocks -> Expectation
-testList bs st res = runState (bottomUpM (References.List.listOf defaultOptions) (toList bs)) st `shouldBe` (toList res,st)
+testList :: Blocks -> (References -> References) -> Blocks -> Expectation
+testList bs st res = testState (bottomUpM References.List.listOf) (st def) bs (res, st)
figure :: T.Text -> T.Text -> T.Text -> T.Text -> Blocks
figure = (((para .) .) .) . figure' "fig:"
@@ -404,13 +439,12 @@ paraText :: T.Text -> Blocks
paraText s = para $ text s
codeBlockDiv :: T.Text -> T.Text -> Blocks
-codeBlockDiv title ref = divWith ("lst:"<>ref, ["listing","haskell"],[]) $
- para (text title) <>
- codeBlockWith
- ("",["haskell"],[]) "main :: IO ()"
+codeBlockDiv title ref = divWith ("lst:"<>ref, [], []) $
+ codeBlockWith ("",["haskell"],[]) "main :: IO ()"
+ <> para (text $ ": " <> title)
codeBlockDiv' :: T.Text -> T.Text -> Blocks
-codeBlockDiv' title ref = divWith ("lst:"<>ref, ["listing"],[]) $
+codeBlockDiv' title ref = divWith ("lst:"<>ref, [],[]) $
para (text title) <>
codeBlockWith
("",["haskell"],[]) "main :: IO ()"
@@ -420,7 +454,7 @@ ref' p n | T.null n = mempty
| otherwise = space <> str ("{#"<>p<>":"<>n<>"}")
defaultOptions :: Options
-defaultOptions = getOptions defaultMeta Nothing
+defaultOptions = getOptions (defaultMeta mempty) Nothing
defCit :: Citation
defCit = Citation{citationId = ""
@@ -435,5 +469,8 @@ cit :: T.Text -> [Citation]
cit r = [defCit{citationId=r}]
infixr 0 =:
-(=:) :: Df.Default r => Accessor r a -> a -> r
-a =: b = a ^= b $ def
+(=:) :: Accessor r a -> a -> r -> r
+a =: b = a ^= b
+
+defaultPrefixes :: Prefixes
+defaultPrefixes = getPrefixes Nothing "prefixes" (defaultMeta mempty)